This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C PATCH for c/71583 (ICE with bogus compound literal)


Since r157233, build_compound_literal will return error_mark_node for
erroneous initializers of compound literals.  This caused an ICE in
c_parser_postfix_expression_after_paren_type because the code dealing
with evaluating variably modified types wasn't prepared for expr.value
being error_mark_node.  Fixed thus.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2016-07-28  Marek Polacek  <polacek@redhat.com>

	PR c/71583
	* c-parser.c (c_parser_postfix_expression_after_paren_type): Also
	check expr.value.

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

diff --git gcc/c/c-parser.c gcc/c/c-parser.c
index 8952bca..a86cae2 100644
--- gcc/c/c-parser.c
+++ gcc/c/c-parser.c
@@ -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)
 	{
diff --git gcc/testsuite/gcc.dg/noncompile/pr71583.c gcc/testsuite/gcc.dg/noncompile/pr71583.c
index e69de29..5045b88 100644
--- gcc/testsuite/gcc.dg/noncompile/pr71583.c
+++ gcc/testsuite/gcc.dg/noncompile/pr71583.c
@@ -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" } */
+}

	Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]