This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C PATCH] Tidy up pedwarn_c90


On Mon, Aug 11, 2014 at 08:19:52PM +0000, Joseph S. Myers wrote:
> On Sat, 9 Aug 2014, Marek Polacek wrote:
> 
> > +  /* Maybe we want to issue the C90/C99 compat warning, which is more
> > +     specific than -pedantic.  */
> > +  if (warn_c90_c99_compat > 0)
> >      {
> >        diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_WARNING);
> 
> That seems wrong; it means that -Wc90-c99-compat turns errors from 
> -pedantic-errors into warnings.  E.g.
> 
> const const int i;
> 
> with -std=c90 -pedantic-errors gets an error, but (with this patch 
> applied) with -Wc90-c99-compat it becomes a warning.
> 
> (In view of this problem I haven't reviewed the rest of this patch.)

Ah, ok, I thought that this is desirable.  I'll adjust it.
 
> > diff --git gcc/gcc/c/c-parser.c gcc/gcc/c/c-parser.c
> > index ca8577c..454f279 100644
> > --- gcc/gcc/c/c-parser.c
> > +++ gcc/gcc/c/c-parser.c
> > @@ -1073,7 +1073,10 @@ disable_extension_diagnostics (void)
> >  	     | (warn_long_long << 4)
> >  	     | (warn_cxx_compat << 5)
> >  	     | (warn_overlength_strings << 6)
> > -	     | (warn_c90_c99_compat << 7));
> > +	     /* warn_c90_c99_compat has three states: -1/0/1, so we must
> > +		play tricks to properly restore it.  */
> > +	     | (warn_c90_c99_compat << 7)
> > +	     | ((warn_c90_c99_compat == -1) << 8));
> 
> This doesn't make sense to me either.  You're left-shifting a negative 
> value (undefined behavior in ISO C, so should be avoided anyway), and left 
> shifting -1 means that all the bits to the left of bit 7 in the result 
> will also be set so can't be used to carry any other information (in 
> particular bit 8 will be set, so this code will in fact work, but by 
> accident).

Oops, sneaky.  I haven't noticed that when I made warn_c90_c99_compat be
initialized to -1 :(.

The patch for -Wc99-c11-compat I posted today has the same issues, so
please ignore that one for now - I'll send a better version tomorrow.

	Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]