Hi!

On the following testcase we ICE during error recovery.
Setting DECL_INITIAL of a FUNCTION_DECL to error_mark_node can't
be possibly helpful, the error must have been diagnosed already;
DECL_INITIAL on the FUNCTION_DECL should be kept as BLOCK.

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

2015-01-26  Jakub Jelinek  <ja...@redhat.com>

        PR c/64766
        * c-typeck.c (store_init_value): Don't overwrite DECL_INITIAL
        of FUNCTION_DECLs with error_mark_node.

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

--- gcc/c/c-typeck.c.jj 2015-01-26 12:09:57.000000000 +0100
+++ gcc/c/c-typeck.c    2015-01-26 14:13:08.142325547 +0100
@@ -6422,7 +6422,8 @@ store_init_value (location_t init_loc, t
     warning (OPT_Wtraditional, "traditional C rejects automatic "
             "aggregate initialization");
 
-  DECL_INITIAL (decl) = value;
+  if (value != error_mark_node || TREE_CODE (decl) != FUNCTION_DECL)
+    DECL_INITIAL (decl) = value;
 
   /* ANSI wants warnings about out-of-range constant initializers.  */
   STRIP_TYPE_NOPS (value);
--- gcc/testsuite/gcc.dg/pr64766.c.jj   2015-01-26 14:20:25.023822836 +0100
+++ gcc/testsuite/gcc.dg/pr64766.c      2015-01-26 14:20:07.000000000 +0100
@@ -0,0 +1,9 @@
+/* PR c/64766 */
+/* { dg-do compile } */
+
+void
+foo ()
+{
+}
+
+void foo () = 0; /* { dg-error "is initialized like a variable|invalid 
initializer" } */

        Jakub

Reply via email to