gamiddon@maytag.waterloo.edu (Guy Middleton) (05/28/90)
This code works everywhere except on my MIPS machine: typedef enum Foo { None=0, Some, All } Foo; main() { Foo x, y; x = (None<<2)|Some; switch (x) { case (((unsigned)None)<<2)|(((unsigned)Some)): printf( "blah\n" ); break; } } MIPS cc says: ccom: Error: enum.c, line 13: non-constant case expression case (((unsigned)None)<<2)|(((unsigned)Some)): -----------------------------------------------^
nagamatu@sm.sony.co.jp (Tatsuo Nagamatu) (05/29/90)
In article <1990May28.152151.5506@maytag.waterloo.edu> gamiddon@maytag.waterloo.edu (Guy Middleton) writes: >This code works everywhere except on my MIPS machine: I simplyfy the posted source code as follows: % cat a.c main () { int x; switch (x) { case ((unsigned)0x10 << 2): printf ("blah\n"); break; } } Ccom can produce the debug message of building tree structure like this: % /usr/lib/cmplrs/cc/ccom -Xb a.c In the debug message, we can see the followings. 2001031760) CAST, unsigned, 16, 14 2001031600) NAME, 0, -1, unsigned, 16, 14 2001032050) SCONV, unsigned, 0, 14 2001031670) ICON, 16, 16384, int, 0, 4 With this message, MIPS C compiler can't pre-calculation of the constant casting. SCONV for constant is not nessesary. 2001031760) CAST, unsigned, 16, 14 2001031600) NAME, 0, -1, unsigned, 16, 14 2001031670) ICON, 16, 16384, unsigned, 0, 4 ~~~~~~~~ Is this bug is included in version 2.1? -- $@%=%K!<(J($@3t(J)$@%9!<%Q!<%^%$%/%m;v6HK\It%o!<%/%9%F!<%7%g%s;v6HIt(J $@1J>>(J $@N5IW(J nagamatu@sm.sony.co.jp
lai@mips.COM (David Lai) (05/30/90)
In article <1990May28.152151.5506@maytag.waterloo.edu> gamiddon@maytag.waterloo.edu (Guy Middleton) writes: >This code works everywhere except on my MIPS machine: > >typedef enum Foo { > None=0, > Some, > All >} Foo; > >main() { > Foo x, y; > > x = (None<<2)|Some; > > switch (x) { > case (((unsigned)None)<<2)|(((unsigned)Some)): > printf( "blah\n" ); > break; > } >} > >MIPS cc says: >ccom: Error: enum.c, line 13: non-constant case expression > case (((unsigned)None)<<2)|(((unsigned)Some)): > -----------------------------------------------^ Bug has been fixed for the 2.10 release: lai> cat x.c typedef enum Foo { None=0, Some, All } Foo; main() { Foo x, y; x = (None<<2)|Some; switch (x) { case (((unsigned)None)<<2)|(((unsigned)Some)): printf( "blah\n" ); break; } } lai> cc -o x x.c lai> x blah -- "What is a DJ if he can't scratch?" - Uncle Jamms Army David Lai (lai@mips.com || {ames,prls,pyramid,decwrl}!mips!lai)