From: Matt H. <ma...@cs...> - 2005-08-04 01:16:01
|
> -----Original Message----- > From: Shahar Golan [mailto:sh...@so...] > Sent: Wednesday, August 03, 2005 2:57 AM > To: 'Matt Harren'; 'Benjamin Monate'; cil...@li... > Subject: RE: [CIL users] Spurious warning in Mergecil > > It seems to me that in the case of an initialized variable, > the 'extern' > keyword is more of a courtesy to the reader, notifying that > the variable may also be seen by others. > I see no reason that the compiler should keep it. > > Moreover, in gcc, the following will also compile and link w/out > warning: > > === g1.c === > int x = 77; > ============ > and > === g2.c === > int x; > ============ > > This is a linker issue more than a compiler's one. > CIL could help solve it by adding 'extern' for any global > that is uninitialized, but this will collide with the urge to > initialize all globals. > > Shahar. > Okay, I've updated CIL so that: - When a global variable has both extern storage and an initializer, we ignore the 'extern'. - When merging two global variables with the same name, we suppress the warning that Benjamin saw if only one of them has an initializer, or report an error if they both have (different) initializers. Cheers, Matt |