aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2010-12-17 21:23:36 +0000
committerPaolo Bonzini <bonzini@gcc.gnu.org>2010-12-17 21:23:36 +0000
commit29ce73cb955296716da85268e4b8faf91e6c5fcf (patch)
treec4cfe728320526019a5d30a613a686238e9911e5 /gcc/c-decl.c
parent7f2605707f4089459163f7d767f0ba5e1c9361e6 (diff)
downloadgcc-29ce73cb955296716da85268e4b8faf91e6c5fcf.zip
gcc-29ce73cb955296716da85268e4b8faf91e6c5fcf.tar.gz
gcc-29ce73cb955296716da85268e4b8faf91e6c5fcf.tar.bz2
re PR c/20385 (Lame parse error message for undefined type)
gcc: 2010-12-17 Paolo Bonzini <bonzini@gnu.org> PR c/20385 * function.c (used_types_insert): Handle ERROR_MARK. * c-decl.c (grokdeclarator): Handle ERROR_MARK. (declspecs_add_type): Leave error_mark_node in specs->type. (finish_declspecs): Change it to integer_type_node here. * c-parser.c (c_parser_peek_2nd_token): Move earlier. (enum c_lookahead_kind): New. (c_parser_next_token_starts_typename): New name of c_parser_next_tokens_start_typename. Accept lookahead enum and handle it here instead of... (c_parser_next_tokens_start_declaration): ... here. Call it. (c_parser_declspecs): Accept another argument. Do not exit on C_ID_ID if it is guessed to be an unknown typename. (c_parser_parms_declarator): Use 2nd token to distinguish a K&R declaration from an ANSI declaration starting with an unknown typename. (c_parser_struct_declaration, c_parser_objc_type_name, c_parser_typeof_specifier, c_parser_declarator, c_parser_direct_declarator_inner): Adjust calls. (c_parser_parameter_declaration): Likewise. (c_parser_type_name): Pass back an error_mark_node to the caller. (c_parser_postfix_expression): Do error recovery when c_parser_type_name returns NULL. testsuite: 2010-12-17 Paolo Bonzini <bonzini@gnu.org> PR c/20385 * objc.dg/tls/init-2.m: Adjust. * gcc.dg/noncompile/920923-1.c: Adjust. * gcc.dg/noncompile/pr44517.c: Adjust. * gcc.dg/declspec-18.c: New test. From-SVN: r167999
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 06e01ad..f9672a0 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -4865,6 +4865,8 @@ grokdeclarator (const struct c_declarator *declarator,
tree expr_dummy;
bool expr_const_operands_dummy;
+ if (TREE_CODE (type) == ERROR_MARK)
+ return error_mark_node;
if (expr == NULL)
expr = &expr_dummy;
if (expr_const_operands == NULL)
@@ -9315,9 +9317,9 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
else
specs->type = TREE_TYPE (t);
}
- else if (TREE_CODE (type) != ERROR_MARK)
+ else
{
- if (spec.kind == ctsk_typeof)
+ if (TREE_CODE (type) != ERROR_MARK && spec.kind == ctsk_typeof)
{
specs->typedef_p = true;
if (spec.expr)
@@ -9332,11 +9334,6 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
}
specs->type = type;
}
- else
- {
- /* Set a dummy type here to avoid warning about implicit 'int'. */
- specs->type = integer_type_node;
- }
return specs;
}
@@ -9452,6 +9449,10 @@ finish_declspecs (struct c_declspecs *specs)
gcc_assert (!specs->long_p && !specs->long_long_p && !specs->short_p
&& !specs->signed_p && !specs->unsigned_p
&& !specs->complex_p);
+
+ /* Set a dummy type. */
+ if (TREE_CODE (specs->type) == ERROR_MARK)
+ specs->type = integer_type_node;
return specs;
}