This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR c/35744: ICE with attributes for invalid types
- From: Volker Reichelt <v dot reichelt at netcologne dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 28 Mar 2008 22:43:58 +0100 (CET)
- Subject: [PATCH] Fix PR c/35744: ICE with attributes for invalid types
The following patch fixes several ice-on-invalid-code bugs with attributes.
We attach attributes in decl_attributes even to errorneous variables or
types. This causes crashes later. The patch fixes this by not attaching
attributes to broken variables or types.
Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for mainline?
Regards,
Volker
:ADDPATCH C:
2008-03-28 Volker Reichelt <v.reichelt@netcologne.de>
PR c/35744
* attribs.c (decl_attributes): Return early on errorneous node.
========================================================================
--- gcc/attribs.c 2008-02-24 21:52:20 +0100
+++ gcc/attribs.c 2008-02-24 21:46:23 +0100
@@ -225,6 +225,9 @@ decl_attributes (tree *node, tree attrib
tree a;
tree returned_attrs = NULL_TREE;
+ if (TREE_TYPE (*node) == error_mark_node)
+ return NULL_TREE;
+
if (!attributes_initialized)
init_attributes ();
========================================================================
2008-03-28 Volker Reichelt <v.reichelt@netcologne.de>
PR c/35744
* testsuite/gcc.dg/attr-error-1.c: New test.
========================================================================
--- gcc/testsuite/gcc.dg/attr-error-1.c 2003-09-23 19:59:22 +0200
+++ gcc/testsuite/gcc.dg/attr-error-1.c 2008-02-24 22:06:29 +0100
@@ -0,0 +1,12 @@
+/* PR c/35744 */
+
+typedef char a[N] __attribute__((aligned(4))); /* { dg-error "undeclared" } */
+
+void c[1] __attribute__((vector_size(8))); /* { dg-error "array of voids" } */
+
+void b[1] __attribute__((may_alias)); /* { dg-error "array of voids" } */
+
+struct A
+{
+ void d[1] __attribute__((packed)); /* { dg-error "array of voids" } */
+};
========================================================================