re PR c/71583 (ICE on invalid code on x86_64-linux-gnu (in c_parser_postfix_expressio...
authorMarek Polacek <polacek@redhat.com>
Fri, 29 Jul 2016 11:48:36 +0000 (11:48 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 29 Jul 2016 11:48:36 +0000 (11:48 +0000)
PR c/71583
* c-parser.c (c_parser_postfix_expression_after_paren_type): Also
check expr.value.

* gcc.dg/noncompile/pr71583.c: New test.

From-SVN: r238861

gcc/c/ChangeLog
gcc/c/c-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/noncompile/pr71583.c [new file with mode: 0644]

index b1c42ff4ca536f09b82377c0bf971033f53889d7..a47b8a3b5edf4ef51c73cc5078ce8c766ceb1795 100644 (file)
@@ -1,3 +1,9 @@
+2016-07-29  Marek Polacek  <polacek@redhat.com>
+
+       PR c/71583
+       * c-parser.c (c_parser_postfix_expression_after_paren_type): Also
+       check expr.value.
+
 2016-07-22  Uros Bizjak  <ubizjak@gmail.com>
 
        * c-typeck.c: Use HOST_WIDE_INT_1 instead of (HOST_WIDE_INT) 1,
index 8952bca363a72b67bc1b88c1ba413ac4732564a8..a86cae29940f188fe0443560c5aa3051e181cb3b 100644 (file)
@@ -8232,7 +8232,9 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser,
   set_c_expr_source_range (&expr, init.src_range);
   expr.original_code = ERROR_MARK;
   expr.original_type = NULL;
-  if (type != error_mark_node && type_expr)
+  if (type != error_mark_node
+      && expr.value != error_mark_node
+      && type_expr)
     {
       if (TREE_CODE (expr.value) == C_MAYBE_CONST_EXPR)
        {
index 9960fb0c4ac7971a988729c04e9162c0169bf350..c1df9e98b1a1b5ebeadc925d99ca0b01c2abd68d 100644 (file)
@@ -3,6 +3,9 @@
        PR c/71574
        * c-c++-common/pr71574.c: New test.
 
+       PR c/71583
+       * gcc.dg/noncompile/pr71583.c: New test.
+
 2016-07-29  Kugan Vivekanandarajah  <kuganv@linaro.org>
 
        PR middle-end/68217
diff --git a/gcc/testsuite/gcc.dg/noncompile/pr71583.c b/gcc/testsuite/gcc.dg/noncompile/pr71583.c
new file mode 100644 (file)
index 0000000..5045b88
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR c/71583 */
+/* { dg-do compile } */
+
+void
+f (int i)
+{
+  (int (*)[++i]) { int }; /* { dg-error "expected" } */
+  (int (*)[++i]) { }; /* { dg-error "empty" } */
+  (int (*)[++i]) { , }; /* { dg-error "expected" } */
+  (int (*)[++i]) { f () }; /* { dg-error "too few" } */
+}