From bfcfbfa0d18abea5f6ced6ec4de409aa3810733e Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 5 Nov 2015 18:21:30 +0000 Subject: [PATCH] re PR c/68090 (VLA compound literal -- "confused by earlier errors, bailing out") 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 | 6 ++++++ gcc/c/c-parser.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr68090.c | 13 +++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr68090.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 9c39fd9d46d..7839024cc88 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2015-11-05 Marek Polacek + + 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 Ilya Verbin diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index ab324d349c1..e2f55b354d1 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -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) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bcf909635b6..2727d7da424 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-11-05 Marek Polacek + + PR c/68090 + * gcc.dg/pr68090.c: New test. + 2015-11-05 James Greenhalgh * 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 index 00000000000..87b3b93ed03 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr68090.c @@ -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" } */ +} -- 2.30.2