aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-parser.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-08-10 06:10:49 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-08-10 06:10:49 +0000
commitf3bede718836610fd741175f4a1b74ba5717e283 (patch)
treead84805c19739010caa9af61cb0d2c384e5aa852 /gcc/c/c-parser.c
parent7a9f1eed30e169e4d1cfbe4167190db495213406 (diff)
downloadgcc-f3bede718836610fd741175f4a1b74ba5717e283.zip
gcc-f3bede718836610fd741175f4a1b74ba5717e283.tar.gz
gcc-f3bede718836610fd741175f4a1b74ba5717e283.tar.bz2
re PR c/51849 (-Wc99-compat would be considered useful)
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. From-SVN: r213786
Diffstat (limited to 'gcc/c/c-parser.c')
-rw-r--r--gcc/c/c-parser.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index e32bf04..ca8577c 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -1072,7 +1072,8 @@ disable_extension_diagnostics (void)
| (flag_iso << 3)
| (warn_long_long << 4)
| (warn_cxx_compat << 5)
- | (warn_overlength_strings << 6));
+ | (warn_overlength_strings << 6)
+ | (warn_c90_c99_compat << 7));
cpp_opts->cpp_pedantic = pedantic = 0;
warn_pointer_arith = 0;
cpp_opts->cpp_warn_traditional = warn_traditional = 0;
@@ -1080,6 +1081,7 @@ disable_extension_diagnostics (void)
cpp_opts->cpp_warn_long_long = warn_long_long = 0;
warn_cxx_compat = 0;
warn_overlength_strings = 0;
+ warn_c90_c99_compat = 0;
return ret;
}
@@ -1096,6 +1098,7 @@ restore_extension_diagnostics (int flags)
cpp_opts->cpp_warn_long_long = warn_long_long = (flags >> 4) & 1;
warn_cxx_compat = (flags >> 5) & 1;
warn_overlength_strings = (flags >> 6) & 1;
+ warn_c90_c99_compat = (flags >> 7) & 1;
}
/* Possibly kinds of declarator to parse. */
@@ -2545,8 +2548,9 @@ c_parser_enum_specifier (c_parser *parser)
}
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
{
- if (seen_comma && !flag_isoc99)
- pedwarn (comma_loc, OPT_Wpedantic, "comma at end of enumerator list");
+ if (seen_comma)
+ pedwarn_c90 (comma_loc, OPT_Wpedantic,
+ "comma at end of enumerator list");
c_parser_consume_token (parser);
break;
}
@@ -4348,9 +4352,9 @@ c_parser_initelt (c_parser *parser, struct obstack * braced_init_obstack)
{
if (c_parser_next_token_is (parser, CPP_EQ))
{
- if (!flag_isoc99)
- pedwarn (des_loc, OPT_Wpedantic,
- "ISO C90 forbids specifying subobject to initialize");
+ pedwarn_c90 (des_loc, OPT_Wpedantic,
+ "ISO C90 forbids specifying subobject "
+ "to initialize");
c_parser_consume_token (parser);
}
else
@@ -4566,10 +4570,9 @@ c_parser_compound_statement_nostart (c_parser *parser)
c_parser_declaration_or_fndef (parser, true, true, true, true,
true, NULL, vNULL);
if (last_stmt)
- pedwarn_c90 (loc,
- (pedantic && !flag_isoc99)
- ? OPT_Wpedantic
- : OPT_Wdeclaration_after_statement,
+ pedwarn_c90 (loc, (pedantic && !flag_isoc99)
+ ? OPT_Wpedantic
+ : OPT_Wdeclaration_after_statement,
"ISO C90 forbids mixed declarations and code");
last_stmt = false;
}
@@ -4598,8 +4601,8 @@ c_parser_compound_statement_nostart (c_parser *parser)
restore_extension_diagnostics (ext);
if (last_stmt)
pedwarn_c90 (loc, (pedantic && !flag_isoc99)
- ? OPT_Wpedantic
- : OPT_Wdeclaration_after_statement,
+ ? OPT_Wpedantic
+ : OPT_Wdeclaration_after_statement,
"ISO C90 forbids mixed declarations and code");
last_stmt = false;
}
@@ -7401,9 +7404,8 @@ c_parser_postfix_expression (c_parser *parser)
expr.value = error_mark_node;
break;
}
- if (!flag_isoc99)
- pedwarn (loc, OPT_Wpedantic,
- "ISO C90 does not support complex types");
+ pedwarn_c90 (loc, OPT_Wpedantic,
+ "ISO C90 does not support complex types");
expr.value = build2 (COMPLEX_EXPR,
build_complex_type
(TYPE_MAIN_VARIANT
@@ -7607,8 +7609,7 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser,
type = error_mark_node;
}
- if (!flag_isoc99)
- pedwarn (start_loc, OPT_Wpedantic, "ISO C90 forbids compound literals");
+ pedwarn_c90 (start_loc, OPT_Wpedantic, "ISO C90 forbids compound literals");
non_const = ((init.value && TREE_CODE (init.value) == CONSTRUCTOR)
? CONSTRUCTOR_NON_CONST (init.value)
: init.original_code == C_MAYBE_CONST_EXPR);