This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix PR c++/28387: ICE with attribute on invalid declaration


The C++ frontend currently ICEs on the following code:

  enum __attribute__((unused)) E;
 
bug.cc:1: error: use of enum 'E' without previous declaration
bug.cc:1: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in decl_attributes, at attribs.c:281
Please submit a full bug report, [etc.]

The patch below fixes the problem by making the checks in
cplus_decl_attributes more robust.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline?

Regards,
Volker

:ADDPATCH C++:


2006-07-14  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/28387
	* decl2.c (cplus_decl_attributes): Check for invalid decls.

===================================================================
--- gcc/gcc/cp/decl2.c	(revision 115431)
+++ gcc/gcc/cp/decl2.c	(working copy)
@@ -997,7 +997,8 @@ cplus_decl_attributes (tree *decl, tree
 void
 cplus_decl_attributes (tree *decl, tree attributes, int flags)
 {
-  if (*decl == NULL_TREE || *decl == void_type_node)
+  if (*decl == NULL_TREE || *decl == void_type_node
+      || *decl == error_mark_node)
     return;
 
   if (TREE_CODE (*decl) == TEMPLATE_DECL)
===================================================================

2006-07-14  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/28387
	* g++.dg/ext/attrib24.C: New test.

===================================================================
--- gcc/gcc/testsuite/g++.dg/ext/attrib24.C	2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/ext/attrib24.C	2006-07-14 16:46:59 +0200
@@ -0,0 +1,4 @@
+// PR c++/28387
+// { dg-do compile }
+
+enum __attribute__((unused)) E;  // { dg-error "without previous declaration" }
===================================================================



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]