Bug 51849 - -Wc99-compat would be considered useful
Summary: -Wc99-compat would be considered useful
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.7.0
: P3 enhancement
Target Milestone: 5.0
Assignee: Marek Polacek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-13 17:26 UTC by Benjamin Kosnik
Modified: 2014-08-10 06:13 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-01-16 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Kosnik 2012-01-13 17:26:43 UTC
The default "C" language dialect for GCC is gnu89. To ease the transition to the eventual switch to gnu99, a warning flag is desired that can flag potentially changed language features between C89 and C99, much like -Wc++11-compat helps programmers transition from C++03 to C++11.

See some of the commentary from Joseph here:
http://gcc.gnu.org/ml/gcc/2012-01/msg00126.html
Comment 1 Marek Polacek 2014-06-30 16:20:12 UTC
I'd like to experiment with this one, so taking for now.
Comment 2 Marek Polacek 2014-08-10 06:12:35 UTC
Author: mpolacek
Date: Sun Aug 10 06:10:49 2014
New Revision: 213786

URL: https://gcc.gnu.org/viewcvs?rev=213786&root=gcc&view=rev
Log:
	PR c/51849
gcc/
	* gcc/doc/invoke.texi: Document -Wc90-c99-compat.
gcc/c-family/
	* c-opts.c (sanitize_cpp_opts): Pass warn_c90_c99_compat to libcpp.
	* c.opt (Wc90-c99-compat): Add option.
gcc/c/
	* c-decl.c (build_array_declarator): Remove check for !flag_isoc99.
	Call pedwarn_c90 instead of pedwarn.
	(check_bitfield_type_and_width): Likewise.
	(declspecs_add_qual): Likewise.
	(declspecs_add_type): Likewise.
	(warn_variable_length_array): Unify function for -pedantic and -Wvla.
	Adjust to only call pedwarn_c90.
	(grokdeclarator): Remove pedantic && !flag_isoc99 check.  Call
	pedwarn_c90 instead of pedwarn.
	* c-errors.c (pedwarn_c90): Handle -Wc90-c99-compat.
	* c-parser.c (disable_extension_diagnostics): Handle
	warn_c90_c99_compat.
	(restore_extension_diagnostics): Likewise.
	(c_parser_enum_specifier): Remove check for !flag_isoc99.  Call
	pedwarn_c90 instead of pedwarn.
	(c_parser_initelt): Likewise.
	(c_parser_postfix_expression): Likewise.
	(c_parser_postfix_expression_after_paren_type): Likewise.
	(c_parser_compound_statement_nostart): Remove check for !flag_isoc99.
	* c-tree.h: Fix formatting.
	* c-typeck.c (build_array_ref): Remove check for !flag_isoc99.  Call
	pedwarn_c90 instead of pedwarn.
gcc/testsuite/
	* gcc.dg/Wc90-c99-compat-1.c: New test.
	* gcc.dg/Wc90-c99-compat-2.c: New test.
	* gcc.dg/Wc90-c99-compat-3.c: New test.
	* gcc.dg/Wc90-c99-compat-4.c: New test.
	* gcc.dg/Wc90-c99-compat-5.c: New test.
	* gcc.dg/Wc90-c99-compat-6.c: New test.
	* gcc.dg/wvla-1.c: Adjust dg-warning.
	* gcc.dg/wvla-2.c: Adjust dg-warning.
	* gcc.dg/wvla-4.c: Adjust dg-warning.
	* gcc.dg/wvla-6.c: Adjust dg-warning.
libcpp/
	* lex.c (_cpp_lex_direct): Warn when -Wc90-c99-compat is in effect.
	* charset.c (_cpp_valid_ucn): Likewise.
	* include/cpplib.h (cpp_options): Add cpp_warn_c90_c99_compat.
	* macro.c (replace_args): Warn when -Wc90-c99-compat is in effect.
	(parse_params): Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/Wc90-c99-compat-1.c
    trunk/gcc/testsuite/gcc.dg/Wc90-c99-compat-2.c
    trunk/gcc/testsuite/gcc.dg/Wc90-c99-compat-3.c
    trunk/gcc/testsuite/gcc.dg/Wc90-c99-compat-4.c
    trunk/gcc/testsuite/gcc.dg/Wc90-c99-compat-5.c
    trunk/gcc/testsuite/gcc.dg/Wc90-c99-compat-6.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-opts.c
    trunk/gcc/c-family/c.opt
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/c/c-errors.c
    trunk/gcc/c/c-parser.c
    trunk/gcc/c/c-tree.h
    trunk/gcc/c/c-typeck.c
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/wvla-1.c
    trunk/gcc/testsuite/gcc.dg/wvla-2.c
    trunk/gcc/testsuite/gcc.dg/wvla-4.c
    trunk/gcc/testsuite/gcc.dg/wvla-6.c
    trunk/libcpp/ChangeLog
    trunk/libcpp/charset.c
    trunk/libcpp/include/cpplib.h
    trunk/libcpp/lex.c
    trunk/libcpp/macro.c
Comment 3 Marek Polacek 2014-08-10 06:13:35 UTC
-Wc90-c99-compat has been added.