re PR middle-end/64766 (internal compiler error: tree check: expected block, have...
authorJakub Jelinek <jakub@redhat.com>
Tue, 27 Jan 2015 08:13:45 +0000 (09:13 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 27 Jan 2015 08:13:45 +0000 (09:13 +0100)
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.

From-SVN: r220152

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

index f361e7cb77f589efea5382f3be0f694316aa8a8e..408fc163ab7dc50314894ab3c31c2ff7c85e002a 100644 (file)
@@ -1,3 +1,9 @@
+2015-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/64766
+       * c-typeck.c (store_init_value): Don't overwrite DECL_INITIAL
+       of FUNCTION_DECLs with error_mark_node.
+
 2015-01-26  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/64778
index 09b1bdf389386480dc77ffb2e0e2f40e59937751..aa74968d28b2d91be365561d17dccd9a92dee6a1 100644 (file)
@@ -6422,7 +6422,8 @@ store_init_value (location_t init_loc, tree decl, tree init, tree origtype)
     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);
index c66df2007d6fafbd9f7ddea612a11dffb1117230..57a58b40a14c6cae304ba642459ebf47aab08bca 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/64766
+       * gcc.dg/pr64766.c: New test.
+
 2015-01-26  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/49263
diff --git a/gcc/testsuite/gcc.dg/pr64766.c b/gcc/testsuite/gcc.dg/pr64766.c
new file mode 100644 (file)
index 0000000..bf6fb2d
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR c/64766 */
+/* { dg-do compile } */
+
+void
+foo ()
+{
+}
+
+void foo () = 0; /* { dg-error "is initialized like a variable|invalid initializer" } */