summaryrefslogtreecommitdiff
path: root/gcc/c-parser.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2008-09-01 06:35:08 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2008-09-01 06:35:08 +0000
commita30fe044170c44da9e441535e2167ca8e885b3cb (patch)
tree2ebaaed9567b6d2c562b45ef1d92bcb5cb136795 /gcc/c-parser.c
parentddda25955ee583217ccbd7ad5c33c6bb9f304649 (diff)
downloadgcc-a30fe044170c44da9e441535e2167ca8e885b3cb.tar.gz
2008-09-01 Basile Starynkevitch <basile@starynkevitch.net>
MERGED WITH TRUNK rev139820 * gcc/melt/warmelt-first.bysl: added location argument to inform. * gcc/warmelt-first-0.c: regenerated. * gcc/warmelt-macro-0.c: regenerated. * gcc/warmelt-normal-0.c: regenerated. * gcc/warmelt-genobj-0.c: regenerated. * gcc/warmelt-outobj-0.c: regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@139849 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r--gcc/c-parser.c137
1 files changed, 67 insertions, 70 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index 1ea9d07fcdf..e69b0a73869 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -805,6 +805,9 @@ c_parser_skip_to_end_of_block_or_statement (c_parser *parser)
parser->error = false;
}
+/* CPP's options (initialized by c-opts.c). */
+extern cpp_options *cpp_opts;
+
/* Save the warning flags which are controlled by __extension__. */
static inline int
@@ -813,11 +816,15 @@ disable_extension_diagnostics (void)
int ret = (pedantic
| (warn_pointer_arith << 1)
| (warn_traditional << 2)
- | (flag_iso << 3));
- pedantic = 0;
+ | (flag_iso << 3)
+ | (warn_long_long << 4)
+ | (cpp_opts->warn_long_long << 5));
+ cpp_opts->pedantic = pedantic = 0;
warn_pointer_arith = 0;
- warn_traditional = 0;
+ cpp_opts->warn_traditional = warn_traditional = 0;
flag_iso = 0;
+ warn_long_long = 0;
+ cpp_opts->warn_long_long = 0;
return ret;
}
@@ -827,10 +834,12 @@ disable_extension_diagnostics (void)
static inline void
restore_extension_diagnostics (int flags)
{
- pedantic = flags & 1;
+ cpp_opts->pedantic = pedantic = flags & 1;
warn_pointer_arith = (flags >> 1) & 1;
- warn_traditional = (flags >> 2) & 1;
+ cpp_opts->warn_traditional = warn_traditional = (flags >> 2) & 1;
flag_iso = (flags >> 3) & 1;
+ warn_long_long = (flags >> 4) & 1;
+ cpp_opts->warn_long_long = (flags >> 5) & 1;
}
/* Possibly kinds of declarator to parse. */
@@ -958,8 +967,8 @@ c_parser_translation_unit (c_parser *parser)
{
if (c_parser_next_token_is (parser, CPP_EOF))
{
- pedwarn (OPT_pedantic, "%HISO C forbids an empty translation unit",
- &c_parser_peek_token (parser)->location);
+ pedwarn (c_parser_peek_token (parser)->location, OPT_pedantic,
+ "ISO C forbids an empty translation unit");
}
else
{
@@ -1043,9 +1052,8 @@ c_parser_external_declaration (c_parser *parser)
}
break;
case CPP_SEMICOLON:
- pedwarn (OPT_pedantic,
- "%HISO C does not allow extra %<;%> outside of a function",
- &c_parser_peek_token (parser)->location);
+ pedwarn (c_parser_peek_token (parser)->location, OPT_pedantic,
+ "ISO C does not allow extra %<;%> outside of a function");
c_parser_consume_token (parser);
break;
case CPP_PRAGMA:
@@ -1159,7 +1167,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
else
{
shadow_tag_warned (specs, 1);
- pedwarn (0, "%Hempty declaration", &here);
+ pedwarn (here, 0, "empty declaration");
}
c_parser_consume_token (parser);
return;
@@ -1195,8 +1203,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
if (!diagnosed_no_specs && !specs->declspecs_seen_p)
{
diagnosed_no_specs = true;
- pedwarn (0, "%Hdata definition has no type or storage class",
- &here);
+ pedwarn (here, 0, "data definition has no type or storage class");
}
/* Having seen a data definition, there cannot now be a
function definition. */
@@ -1265,7 +1272,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
/* Function definition (nested or otherwise). */
if (nested)
{
- pedwarn (OPT_pedantic, "%HISO C forbids nested functions", &here);
+ pedwarn (here, OPT_pedantic, "ISO C forbids nested functions");
c_push_function_context ();
}
if (!start_function (specs, declarator, all_prefix_attrs))
@@ -1665,8 +1672,7 @@ c_parser_enum_specifier (c_parser *parser)
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
{
if (seen_comma && !flag_isoc99)
- pedwarn (OPT_pedantic, "%Hcomma at end of enumerator list",
- &comma_loc);
+ pedwarn (comma_loc, OPT_pedantic, "comma at end of enumerator list");
c_parser_consume_token (parser);
break;
}
@@ -1697,9 +1703,8 @@ c_parser_enum_specifier (c_parser *parser)
if (pedantic && !COMPLETE_TYPE_P (ret.spec))
{
gcc_assert (ident);
- pedwarn (OPT_pedantic,
- "%HISO C forbids forward references to %<enum%> types",
- &ident_loc);
+ pedwarn (ident_loc, OPT_pedantic,
+ "ISO C forbids forward references to %<enum%> types");
}
return ret;
}
@@ -1823,9 +1828,8 @@ c_parser_struct_or_union_specifier (c_parser *parser)
/* Parse any stray semicolon. */
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
- pedwarn (OPT_pedantic,
- "%Hextra semicolon in struct or union specified",
- &c_parser_peek_token (parser)->location);
+ pedwarn (c_parser_peek_token (parser)->location, OPT_pedantic,
+ "extra semicolon in struct or union specified");
c_parser_consume_token (parser);
continue;
}
@@ -1853,8 +1857,8 @@ c_parser_struct_or_union_specifier (c_parser *parser)
else
{
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
- pedwarn (0, "%Hno semicolon at end of struct or union",
- &c_parser_peek_token (parser)->location);
+ pedwarn (c_parser_peek_token (parser)->location, 0,
+ "no semicolon at end of struct or union");
else
{
c_parser_error (parser, "expected %<;%>");
@@ -1945,9 +1949,8 @@ c_parser_struct_declaration (c_parser *parser)
tree ret;
if (!specs->type_seen_p)
{
- pedwarn (OPT_pedantic,
- "%HISO C forbids member declarations with no members",
- &decl_loc);
+ pedwarn (decl_loc, OPT_pedantic,
+ "ISO C forbids member declarations with no members");
shadow_tag_warned (specs, pedantic);
ret = NULL_TREE;
}
@@ -1957,7 +1960,9 @@ c_parser_struct_declaration (c_parser *parser)
structs or unions (which is [a] useful and [b] supports
MS P-SDK). */
tree attrs = NULL;
- ret = grokfield (build_id_declarator (NULL_TREE), specs,
+
+ ret = grokfield (c_parser_peek_token (parser)->location,
+ build_id_declarator (NULL_TREE), specs,
NULL_TREE, &attrs);
if (ret)
decl_attributes (&ret, attrs, 0);
@@ -2000,7 +2005,8 @@ c_parser_struct_declaration (c_parser *parser)
}
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
postfix_attrs = c_parser_attributes (parser);
- d = grokfield (declarator, specs, width, &all_prefix_attrs);
+ d = grokfield (c_parser_peek_token (parser)->location,
+ declarator, specs, width, &all_prefix_attrs);
decl_attributes (&d, chainon (postfix_attrs,
all_prefix_attrs), 0);
TREE_CHAIN (d) = decls;
@@ -2819,8 +2825,13 @@ c_parser_attributes (c_parser *parser)
}
if (!ok)
break;
+ /* Accept __attribute__((__const)) as __attribute__((const))
+ etc. */
+ attr_name
+ = ridpointers[(int) c_parser_peek_token (parser)->keyword];
}
- attr_name = c_parser_peek_token (parser)->value;
+ else
+ attr_name = c_parser_peek_token (parser)->value;
c_parser_consume_token (parser);
if (c_parser_next_token_is_not (parser, CPP_OPEN_PAREN))
{
@@ -3000,8 +3011,7 @@ c_parser_braced_init (c_parser *parser, tree type, bool nested_p)
really_start_incremental_init (type);
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
{
- pedwarn (OPT_pedantic, "%HISO C forbids empty initializer braces",
- &brace_loc);
+ pedwarn (brace_loc, OPT_pedantic, "ISO C forbids empty initializer braces");
}
else
{
@@ -3046,9 +3056,8 @@ c_parser_initelt (c_parser *parser)
/* Old-style structure member designator. */
set_init_label (c_parser_peek_token (parser)->value);
/* Use the colon as the error location. */
- pedwarn (OPT_pedantic,
- "%Hobsolete use of designated initializer with %<:%>",
- &c_parser_peek_2nd_token (parser)->location);
+ pedwarn (c_parser_peek_2nd_token (parser)->location, OPT_pedantic,
+ "obsolete use of designated initializer with %<:%>");
c_parser_consume_token (parser);
c_parser_consume_token (parser);
}
@@ -3177,9 +3186,8 @@ c_parser_initelt (c_parser *parser)
c_parser_consume_token (parser);
set_init_index (first, second);
if (second)
- pedwarn (OPT_pedantic,
- "%HISO C forbids specifying range of "
- "elements to initialize", &ellipsis_loc);
+ pedwarn (ellipsis_loc, OPT_pedantic,
+ "ISO C forbids specifying range of elements to initialize");
}
else
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
@@ -3191,20 +3199,15 @@ c_parser_initelt (c_parser *parser)
if (c_parser_next_token_is (parser, CPP_EQ))
{
if (!flag_isoc99)
- pedwarn (OPT_pedantic,
- "%HISO C90 forbids specifying subobject "
- "to initialize", &des_loc);
+ pedwarn (des_loc, OPT_pedantic,
+ "ISO C90 forbids specifying subobject to initialize");
c_parser_consume_token (parser);
}
else
{
if (des_seen == 1)
- {
- pedwarn (OPT_pedantic,
- "%Hobsolete use of designated initializer "
- "without %<=%>",
- &c_parser_peek_token (parser)->location);
- }
+ pedwarn (c_parser_peek_token (parser)->location, OPT_pedantic,
+ "obsolete use of designated initializer without %<=%>");
else
{
struct c_expr init;
@@ -3354,7 +3357,7 @@ c_parser_compound_statement_nostart (c_parser *parser)
}
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
}
- pedwarn (OPT_pedantic, "%HISO C forbids label declarations", &err_loc);
+ pedwarn (err_loc, OPT_pedantic, "ISO C forbids label declarations");
}
/* We must now have at least one statement, label or declaration. */
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
@@ -3385,11 +3388,11 @@ c_parser_compound_statement_nostart (c_parser *parser)
last_label = false;
c_parser_declaration_or_fndef (parser, true, true, true, true);
if (last_stmt)
- pedwarn_c90 ((pedantic && !flag_isoc99)
+ pedwarn_c90 (loc,
+ (pedantic && !flag_isoc99)
? OPT_pedantic
: OPT_Wdeclaration_after_statement,
- "%HISO C90 forbids mixed declarations and code",
- &loc);
+ "ISO C90 forbids mixed declarations and code");
last_stmt = false;
}
else if (!last_label
@@ -3414,11 +3417,10 @@ c_parser_compound_statement_nostart (c_parser *parser)
disable this diagnostic. */
restore_extension_diagnostics (ext);
if (last_stmt)
- pedwarn_c90 ((pedantic && !flag_isoc99)
+ pedwarn_c90 (loc, (pedantic && !flag_isoc99)
? OPT_pedantic
: OPT_Wdeclaration_after_statement,
- "%HISO C90 forbids mixed declarations and code",
- &loc);
+ "ISO C90 forbids mixed declarations and code");
last_stmt = false;
}
else
@@ -4432,9 +4434,8 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after)
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_COLON))
{
- pedwarn (OPT_pedantic,
- "%HISO C forbids omitting the middle term of a ?: expression",
- &c_parser_peek_token (parser)->location);
+ pedwarn (c_parser_peek_token (parser)->location, OPT_pedantic,
+ "ISO C forbids omitting the middle term of a ?: expression");
/* Make sure first operand is calculated only once. */
exp1.value = save_expr (default_conversion (cond.value));
cond.value = c_objc_common_truthvalue_conversion (exp1.value);
@@ -5136,8 +5137,8 @@ c_parser_postfix_expression (c_parser *parser)
c_parser_compound_statement_nostart (parser);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
- pedwarn (OPT_pedantic,
- "%HISO C forbids braced-groups within expressions", &here);
+ pedwarn (here, OPT_pedantic,
+ "ISO C forbids braced-groups within expressions");
expr.value = c_finish_stmt_expr (stmt);
expr.original_code = ERROR_MARK;
}
@@ -5498,8 +5499,7 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser,
maybe_warn_string_init (type, init);
if (!flag_isoc99)
- pedwarn (OPT_pedantic, "%HISO C90 forbids compound literals",
- &start_loc);
+ pedwarn (start_loc, OPT_pedantic, "ISO C90 forbids compound literals");
expr.value = build_compound_literal (type, init.value);
expr.original_code = ERROR_MARK;
return c_parser_postfix_expression_after_primary (parser, expr);
@@ -5800,9 +5800,8 @@ c_parser_objc_class_instance_variables (c_parser *parser)
/* Parse any stray semicolon. */
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
- pedwarn (OPT_pedantic,
- "%Hextra semicolon in struct or union specified",
- &c_parser_peek_token (parser)->location);
+ pedwarn (c_parser_peek_token (parser)->location, OPT_pedantic,
+ "extra semicolon in struct or union specified");
c_parser_consume_token (parser);
continue;
}
@@ -6018,9 +6017,8 @@ c_parser_objc_method_definition (c_parser *parser)
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
c_parser_consume_token (parser);
- pedwarn (OPT_pedantic,
- "%Hextra semicolon in method definition specified",
- &c_parser_peek_token (parser)->location);
+ pedwarn (c_parser_peek_token (parser)->location, OPT_pedantic,
+ "extra semicolon in method definition specified");
}
if (!c_parser_next_token_is (parser, CPP_OPEN_BRACE))
{
@@ -6056,9 +6054,8 @@ c_parser_objc_methodprotolist (c_parser *parser)
switch (c_parser_peek_token (parser)->type)
{
case CPP_SEMICOLON:
- pedwarn (OPT_pedantic, "%HISO C does not allow extra %<;%> "
- "outside of a function",
- &c_parser_peek_token (parser)->location);
+ pedwarn (c_parser_peek_token (parser)->location, OPT_pedantic,
+ "ISO C does not allow extra %<;%> outside of a function");
c_parser_consume_token (parser);
break;
case CPP_PLUS: