From 913884f792bf4ba684ef4513cf79168d37d86e92 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 1 Jan 2018 00:52:41 +0100 Subject: [PATCH] re PR c/83595 (ICE: in linemap_macro_map_lookup, at libcpp/line-map.c:1008 on invalid code) PR c/83595 * c-parser.c (c_parser_braced_init, c_parser_initelt, c_parser_conditional_expression, c_parser_cast_expression, c_parser_sizeof_expression, c_parser_alignof_expression, c_parser_postfix_expression, c_parser_omp_declare_reduction, c_parser_transaction_expression): Use set_error () method instead of setting value member to error_mark_node. * gcc.dg/pr83595.c: New test. From-SVN: r256054 --- gcc/c/ChangeLog | 10 ++++++++++ gcc/c/c-parser.c | 20 ++++++++++---------- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/pr83595.c | 9 +++++++++ 4 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr83595.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index f76110a62b1..8e6e1fed4f0 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,13 @@ +2018-01-01 Jakub Jelinek + + PR c/83595 + * c-parser.c (c_parser_braced_init, c_parser_initelt, + c_parser_conditional_expression, c_parser_cast_expression, + c_parser_sizeof_expression, c_parser_alignof_expression, + c_parser_postfix_expression, c_parser_omp_declare_reduction, + c_parser_transaction_expression): Use set_error () method instead + of setting value member to error_mark_node. + 2017-12-28 Michael Meissner * c-decl.c (header_for_builtin_fn): Add integer rounding _Float diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 05d1e0fe46e..c27fdaf39f9 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -4582,7 +4582,7 @@ c_parser_braced_init (c_parser *parser, tree type, bool nested_p, c_token *next_tok = c_parser_peek_token (parser); if (next_tok->type != CPP_CLOSE_BRACE) { - ret.value = error_mark_node; + ret.set_error (); ret.original_code = ERROR_MARK; ret.original_type = NULL; braces.skip_until_found_close (parser); @@ -4649,7 +4649,7 @@ c_parser_initelt (c_parser *parser, struct obstack * braced_init_obstack) else { struct c_expr init; - init.value = error_mark_node; + init.set_error (); init.original_code = ERROR_MARK; init.original_type = NULL; c_parser_error (parser, "expected identifier"); @@ -4785,7 +4785,7 @@ c_parser_initelt (c_parser *parser, struct obstack * braced_init_obstack) else { struct c_expr init; - init.value = error_mark_node; + init.set_error (); init.original_code = ERROR_MARK; init.original_type = NULL; c_parser_error (parser, "expected %<=%>"); @@ -6693,7 +6693,7 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after, if (!c_parser_require (parser, CPP_COLON, "expected %<:%>")) { c_inhibit_evaluation_warnings -= cond.value == truthvalue_true_node; - ret.value = error_mark_node; + ret.set_error (); ret.original_code = ERROR_MARK; ret.original_type = NULL; return ret; @@ -7071,7 +7071,7 @@ c_parser_cast_expression (c_parser *parser, struct c_expr *after) parens.skip_until_found_close (parser); if (type_name == NULL) { - ret.value = error_mark_node; + ret.set_error (); ret.original_code = ERROR_MARK; ret.original_type = NULL; return ret; @@ -7297,7 +7297,7 @@ c_parser_sizeof_expression (c_parser *parser) struct c_expr ret; c_inhibit_evaluation_warnings--; in_sizeof--; - ret.value = error_mark_node; + ret.set_error (); ret.original_code = ERROR_MARK; ret.original_type = NULL; return ret; @@ -7383,7 +7383,7 @@ c_parser_alignof_expression (c_parser *parser) struct c_expr ret; c_inhibit_evaluation_warnings--; in_alignof--; - ret.value = error_mark_node; + ret.set_error (); ret.original_code = ERROR_MARK; ret.original_type = NULL; return ret; @@ -7838,7 +7838,7 @@ c_parser_postfix_expression (c_parser *parser) && !targetm.fixed_point_supported_p ()) { error_at (loc, "fixed-point types not supported for this target"); - expr.value = error_mark_node; + expr.set_error (); } break; case CPP_CHAR: @@ -17748,7 +17748,7 @@ c_parser_omp_declare_reduction (c_parser *parser, enum pragma_context context) struct c_expr initializer; tree omp_priv = NULL_TREE, omp_orig = NULL_TREE; bool bad = false; - initializer.value = error_mark_node; + initializer.set_error (); if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) bad = true; else if (c_parser_next_token_is (parser, CPP_NAME) @@ -18305,7 +18305,7 @@ c_parser_transaction_expression (c_parser *parser, enum rid keyword) else { error: - ret.value = error_mark_node; + ret.set_error (); ret.original_code = ERROR_MARK; ret.original_type = NULL; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8b5c062e1f0..a9b2008f2d4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-01-01 Jakub Jelinek + PR c/83595 + * gcc.dg/pr83595.c: New test. + PR middle-end/83608 * g++.dg/opt/pr83608.C: New test. diff --git a/gcc/testsuite/gcc.dg/pr83595.c b/gcc/testsuite/gcc.dg/pr83595.c new file mode 100644 index 00000000000..b67970e5ecc --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr83595.c @@ -0,0 +1,9 @@ +/* PR c/83595 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +foo () +{ + (())((int){0); /* { dg-error "expected expression before" } */ +} -- 2.30.2