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 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.)

> 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).

-- 
Joseph S. Myers
joseph@codesourcery.com


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