From: Sandeep D. <sa...@wi...> - 2001-10-31 19:20:42
|
Johan, I'm still confused .. why does char2 inside the loop have a global scope it has been declared in function ... void c1(void) > > { > > char2 = 9; > > > > for(i=0;i<4;i++) { > > c2(); > > char1=char2; <<== should be 9 > > char0+=char1; > > > > } > > } Sandeep > -----Original Message----- > From: sdc...@li... > [mailto:sdc...@li...]On Behalf Of Johan Knol > Sent: Wednesday, October 31, 2001 11:14 AM > To: Sandeep Dutta; sdc...@li... > Subject: Re: [sdcc-devel] [ sdcc-Bugs-476678 ] Global scoping > is getting > lost > > > In this case the scope isn't local but global. Please look at > my fix in > SDCCloop.c:1.19 > > Normally I reply to this list if I (think I) fixed something, to avoid > waisting other people's time hunting the same bug. This time > I forgot. It > would be easier if not only the initial bug report would be > forwarded to the > list, but also subsequent comments. Micheal? > > Johan > > ----- Original Message ----- > From: Sandeep Dutta <sa...@wi...> > To: <sdc...@li...> > Sent: Wednesday, October 31, 2001 6:55 PM > Subject: RE: [sdcc-devel] [ sdcc-Bugs-476678 ] Global scoping > is getting > lost > > > > 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 > > > > > > > > > > _______________________________________________ > > sdcc-devel mailing list > > sdc...@li... > > https://lists.sourceforge.net/lists/listinfo/sdcc-devel > > > > > _______________________________________________ > sdcc-devel mailing list > sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-devel > > > |