Hi!

The following testcase ICEs during error recovery, because finish_decl
overwrites TREE_TYPE (error_mark_node), which better should stay always
to be error_mark_node.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2021-04-10  Jakub Jelinek  <ja...@redhat.com>

        PR c/99990
        * c-decl.c (finish_decl): Don't overwrite TREE_TYPE of
        error_mark_node.

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

--- gcc/c/c-decl.c.jj   2021-04-08 18:35:11.101520870 +0200
+++ gcc/c/c-decl.c      2021-04-09 14:23:47.101571709 +0200
@@ -5402,7 +5402,7 @@ finish_decl (tree decl, location_t init_
          gcc_unreachable ();
        }
 
-      if (DECL_INITIAL (decl))
+      if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node)
        TREE_TYPE (DECL_INITIAL (decl)) = type;
 
       relayout_decl (decl);
--- gcc/testsuite/gcc.dg/pr99990.c.jj   2021-04-09 14:43:31.479327858 +0200
+++ gcc/testsuite/gcc.dg/pr99990.c      2021-04-09 14:45:18.201134102 +0200
@@ -0,0 +1,12 @@
+/* PR c/99990 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+#include <stdarg.h>
+
+void
+foo ()
+{
+  va_arg (0, long);    /* { dg-error "first argument to 'va_arg' not of type 
'va_list'" } */
+  void *b[] = 0;       /* { dg-error "invalid initializer" } */
+}

        Jakub

Reply via email to