re PR c/83595 (ICE: in linemap_macro_map_lookup, at libcpp/line-map.c:1008 on invalid...
authorJakub Jelinek <jakub@redhat.com>
Sun, 31 Dec 2017 23:52:41 +0000 (00:52 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 31 Dec 2017 23:52:41 +0000 (00:52 +0100)
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
gcc/c/c-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr83595.c [new file with mode: 0644]

index f76110a62b1c6aecdc6723df07dc1ebd5f07bb20..8e6e1fed4f077be80f22f4deb13cf70f94f2c1cf 100644 (file)
@@ -1,3 +1,13 @@
+2018-01-01  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <meissner@linux.vnet.ibm.com>
 
        * c-decl.c (header_for_builtin_fn): Add integer rounding _Float<N>
index 05d1e0fe46ea7894cecb0f0142c8a867371af446..c27fdaf39f970198b952e0b7de801d06d150b5cc 100644 (file)
@@ -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;
     }
index 8b5c062e1f0687b14eb148648cebe99ea8f867a5..a9b2008f2d43a1e842576973e1d394524ffc58ef 100644 (file)
@@ -1,5 +1,8 @@
 2018-01-01  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..b67970e
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR c/83595 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+foo ()
+{
+  (())((int){0);       /* { dg-error "expected expression before" } */
+}