[C PATCH] Implement -Wc90-c99-compat (PR c/51849)

Joseph S. Myers joseph@codesourcery.com
Thu Aug 7 17:10:00 GMT 2014


On Thu, 31 Jul 2014, Marek Polacek wrote:

> A few issues: currently we don't warn (in -std=c90 -pedantic mode)
> about the usage of __func__ and _Pragma (possible others - va_copy?).
> I'm hoping this is not that important though.  For restrict/inline,
> in GNU90 mode we just don't compile the code at all (unless we use
> __restrict and similar), and -Wc90-c99-compat does not warn about those.

And, -pedantic -Wno-c90-c99-compat - outside C99 mode - doesn't disable 
the relevant warnings (I'd think of it as logically like -pedantic 
-Wno-long-long, so it should disable them, while leaving all the -pedantic 
diagnostics for features that aren't in C99).  Though I think implementing 
that could reasonably be a followup fix.

E.g., in C90 mode, -Wlong-long is more specific than -Wc90-c99-compat, 
which is more specific than -pedantic.  So the "long long" warnings should 
be determined by any explicit -W(no-)long-long if given, otherwise by any 
-W(no-)c90-c99-compat if given, otherwise by -pedantic, following the 
general rule of the most specific option taking precedence (and 
command-line order only being relevant when multiple variants of the same 
option are used, e.g. -Wlong-long -Wno-long-long).  Outside C90 mode, 
-pedantic is irrelevant to such warnings; -W(no-)long-long should take 
precedence over -W(no-)c90-c99-compat if both are used.  For warnings 
without a more specific option such as -Wlong-long, of course it's a bit 
simpler.

> @@ -44,21 +44,38 @@ pedwarn_c99 (location_t location, int opt, const char *gmsgid, ...)
>    va_end (ap);
>  }
>  
> -/* Issue an ISO C90 pedantic warning MSGID.  This function is supposed to
> -   be used for matters that are allowed in ISO C99 but not supported in
> -   ISO C90, thus we explicitly don't pedwarn when C99 is specified.
> -   (There is no flag_c90.)  */
> +/* Issue an ISO C90 pedantic warning MSGID if -pedantic outside C99 mode,
> +   otherwise issue warning MSGID if -Wc90-c99-compat is specified, or if
> +   specific option such as -Wlong-long is specified.

"a specific option".

OK with that change.

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list