PR c/98198: ICE-on-invalid-code error recovery.
authorRoger Sayle <roger@nextmovesoftware.com>
Wed, 16 Mar 2022 23:20:34 +0000 (23:20 +0000)
committerRoger Sayle <roger@nextmovesoftware.com>
Wed, 16 Mar 2022 23:20:34 +0000 (23:20 +0000)
This is Christophe Lyon's fix to PR c/98198, an ICE-on-invalid-code
regression affecting mainline, and a suitable testcase.
Tested on x86_64-pc-linux-gnu with make bootstrap and make -k check
with no new failures.  Ok for mainline?

2022-03-16  Christophe Lyon  <christophe.lyon@arm.com>
    Roger Sayle  <roger@nextmovesoftware.com>

gcc/c-family/ChangeLog
PR c/98198
* c-attribs.cc (decl_or_type_attrs): Add error_mark_node check.

gcc/testsuite/ChangeLog
PR c/98198
* gcc.dg/pr98198.c: New test case.

gcc/c-family/c-attribs.cc
gcc/testsuite/gcc.dg/pr98198.c [new file with mode: 0644]

index c885d88..111a33f 100644 (file)
@@ -806,6 +806,8 @@ decl_or_type_attrs (tree node)
        return attrs;
 
       tree type = TREE_TYPE (node);
+      if (type == error_mark_node)
+       return NULL_TREE;
       return TYPE_ATTRIBUTES (type);
     }
 
diff --git a/gcc/testsuite/gcc.dg/pr98198.c b/gcc/testsuite/gcc.dg/pr98198.c
new file mode 100644 (file)
index 0000000..489afae
--- /dev/null
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+static inline void sub_1 ( ) { 
+       struct struct_1 var_9 , var_10
+}
+
+static int var_9[1] __attribute__ ( ( section ( ".data" ) ) ) ; 
+/* { dg-excess-errors "" } */