From: Sandeep D. <sa...@wi...> - 2001-10-31 17:56:33
|
I don't understand.. this is what should happen. if Local variable has same name as a global variable, the local variable will be used.. this is correct ANSI behaviour. Sandeep > -----Original Message----- > From: sdc...@li... > [mailto:sdc...@li...]On Behalf Of > no...@so... > Sent: Tuesday, October 30, 2001 11:41 PM > To: no...@so... > Subject: [sdcc-devel] [ sdcc-Bugs-476678 ] Global scoping is getting > lost > > > Bugs item #476678, was opened at 2001-10-30 23:40 > You can respond by visiting: > http://sourceforge.net/tracker/?func=detail&atid=100599&aid=47 > 6678&group_id=599 > > Category: Icode generator > Group: None > Status: Open > Resolution: None > Priority: 5 > Submitted By: Scott Dattalo (sdattalo) > Assigned to: Nobody/Anonymous (nobody) > Summary: Global scoping is getting lost > > Initial Comment: > > unsigned char char0 = 0; > unsigned char char1 = 0; > unsigned char char2 = 0; > unsigned char i = 0; > > > void c2(void) > { > > char2 = char0+1; > } > > void c1(void) > { > char2 = 9; > > for(i=0;i<4;i++) { > c2(); > char1=char2; > char0+=char1; > > } > } > > --------- > The scope of char2 is getting lost in the assignment > char1=char2; statement. > > e.g.: > sdcc -c -mmcs51 t.c > > <snip> > ; t.c 28 > ; ----------------------------------------- > ; function c1 > ; ----------------------------------------- > _c1: > ; t.c 30 > mov _char2,#0x09 > ; t.c 32 > mov _i,#0x00 > mov r2,#0x09 > 00101$: > clr c > mov a,_i > subb a,#0x04 > ; Peephole 108 removed ljmp by inverse jump logic > jnc 00105$ > 00109$: > ; t.c 33 > push ar2 > lcall _c2 > pop ar2 > ; t.c 34 > mov _char1,r2 > ; t.c 35 > mov a,_char1 > add a,_char0 > mov _char0,a > ; t.c 32 > inc _i > ; Peephole 132 changed ljmp to sjmp > sjmp 00101$ > 00105$: > ret > > <snip> > At t.c 34, the assignment of char1=char2 is actually > being generated as char1=r2, which is scoped locally to > c1(). I'm fairly certain that it's an iCode problem > because I saw this first in the PIC Port. > > Scott > > > ---------------------------------------------------------------------- > > You can respond by visiting: > http://sourceforge.net/tracker/?func=detail&atid=100599&aid=47 6678&group_id=599 _______________________________________________ sdcc-devel mailing list sdc...@li... https://lists.sourceforge.net/lists/listinfo/sdcc-devel |