re PR c/68090 (VLA compound literal -- "confused by earlier errors, bailing out")
authorMarek Polacek <polacek@redhat.com>
Thu, 5 Nov 2015 18:21:30 +0000 (18:21 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 5 Nov 2015 18:21:30 +0000 (18:21 +0000)
PR c/68090
* c-parser.c (c_parser_postfix_expression_after_paren_type): Don't
deal with pre-evaluation on invalid types.

* gcc.dg/pr68090.c: New test.

From-SVN: r229823

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

index 9c39fd9d46dc1460a1f0a79dd0b3aa11ceab3023..7839024cc8875df6031fbfa0bc82ef5d23f2cc45 100644 (file)
@@ -1,3 +1,9 @@
+2015-11-05  Marek Polacek  <polacek@redhat.com>
+
+       PR c/68090
+       * c-parser.c (c_parser_postfix_expression_after_paren_type): Don't
+       deal with pre-evaluation on invalid types.
+
 2015-11-05  Jakub Jelinek  <jakub@redhat.com>
            Ilya Verbin  <ilya.verbin@intel.com>
 
index ab324d349c104a2b69cb89aca8ddb8a2e0031e51..e2f55b354d10e5ce2a9762bbe79af865ea81db29 100644 (file)
@@ -7855,7 +7855,7 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser,
   expr.value = build_compound_literal (start_loc, type, init.value, non_const);
   expr.original_code = ERROR_MARK;
   expr.original_type = NULL;
-  if (type_expr)
+  if (type != error_mark_node && type_expr)
     {
       if (TREE_CODE (expr.value) == C_MAYBE_CONST_EXPR)
        {
index bcf909635b6a9c4d75927a4e5b18a504d84c17d4..2727d7da42419bef1e264fbeb65ebace8a9ad17e 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-05  Marek Polacek  <polacek@redhat.com>
+
+       PR c/68090
+       * gcc.dg/pr68090.c: New test.
+
 2015-11-05  James Greenhalgh  <james.greenhalgh@arm.com>
 
        * gcc.dg/ifcvt-4.c: New.
diff --git a/gcc/testsuite/gcc.dg/pr68090.c b/gcc/testsuite/gcc.dg/pr68090.c
new file mode 100644 (file)
index 0000000..87b3b93
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR c/68090 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+fn (int i)
+{
+  (int[(0, 1)]) { 0 }; /* { dg-error "compound literal has variable size" } */
+  (int[i]) { 0 }; /* { dg-error "compound literal has variable size" } */
+  (int[(0, i)]) { 0 }; /* { dg-error "compound literal has variable size" } */
+  (int [][i]){ 0 }; /* { dg-error "compound literal has variable size" } */
+  (int [][(1, 2)]){ 0 }; /* { dg-error "compound literal has variable size" } */
+}