From: SourceForge.net <no...@so...> - 2009-04-29 15:14:49
|
Bugs item #2783061, was opened at 2009-04-28 18:21 Message generated for change (Comment added) made by keithp You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2783061&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. >Category: Icode generator Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Keith Packard (keithp) Assigned to: Nobody/Anonymous (nobody) Summary: mcs51 varargs functions do not promote pointers to generic Initial Comment: When a varags function (like printf) is passed a non-generic pointer (__code char *, for instance), that argument is not promoted to a generic pointer when pushed on the stack. This is a change from the 2.8 version which did this promotion. The test is small enough to include in-line here: extern void f(char *x, ...); void func(__code char *s) { f("hi", s); } SDCC command: $ sdcc -c --model-small --debug --opt-code-speed -otest.rel test.c SDCC version: SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.9.0 #5416 (Apr 9 2009) (UNIX) Incorrect output (note missing mov a,#0x80; push acc after the push ar3) 0000 AA 82 109 mov r2,dpl 0002 AB 83 110 mov r3,dph 0004 111 C$test.c$6$1$1 ==. 112 ; test.c:6: f("hi", s); 0004 C0 02 113 push ar2 0006 C0 03 114 push ar3 0008 74r00 115 mov a,#__str_0 000A C0 E0 116 push acc 000C 74s00 117 mov a,#(__str_0 >> 8) 000E C0 E0 118 push acc 0010 74 80 119 mov a,#0x80 0012 C0 E0 120 push acc 0014 12s00r00 121 lcall _f Email address: ke...@ke... ---------------------------------------------------------------------- >Comment By: Keith Packard (keithp) Date: 2009-04-29 15:14 Message: On 28 Dec 2008, Maarten Brock added RESULT_TYPE_GPTR as a distinct case from RESULT_TYPE_NONE, but it looks like that didn't include changes to make the varargs parameter passing code use RESULT_TYPE_GPTR in cases that involved passing pointers. I've attached a patch which passes RESULT_TYPE_GPTR for the two pointer cases in the varargs parameter type computation. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2783061&group_id=599 |