diff mbox

[C++] Fix ICE on misplaced attribute (PR c++/52671)

Message ID 20120322193802.GB16117@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek March 22, 2012, 7:38 p.m. UTC
Hi!

The recent change to move the warning about misplaced attributes resulted
in ICE on the following testcase.  The problem is that the ENUMERAL_TYPE
doesn't have type lang specific initialized and so
CLASSTYPE_TEMPLATE_INSTANTIATION macro segfaults.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk/4.7.1?

2012-03-22  Jakub Jelinek  <jakub@redhat.com>

	PR c++/52671
	* decl.c (check_tag_decl): Only use CLASSTYPE_TEMPLATE_INSTANTIATION
	on CLASS_TYPE_P types.

	* g++.dg/ext/attrib44.C: New test.


	Jakub

Comments

Jason Merrill March 22, 2012, 8:22 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

--- gcc/cp/decl.c.jj	2012-03-06 17:02:09.000000000 +0100
+++ gcc/cp/decl.c	2012-03-22 17:20:05.744573734 +0100
@@ -4219,7 +4219,8 @@  check_tag_decl (cp_decl_specifier_seq *d
   if (declspecs->attributes && warn_attributes)
     {
       location_t loc;
-      if (!CLASSTYPE_TEMPLATE_INSTANTIATION (declared_type))
+      if (!CLASS_TYPE_P (declared_type)
+	  || !CLASSTYPE_TEMPLATE_INSTANTIATION (declared_type))
 	/* For a non-template class, use the name location.  */
 	loc = location_of (declared_type);
       else
--- gcc/testsuite/g++.dg/ext/attrib44.C.jj	2012-03-22 17:41:43.469220822 +0100
+++ gcc/testsuite/g++.dg/ext/attrib44.C	2012-03-22 17:41:51.784172016 +0100
@@ -0,0 +1,4 @@ 
+// PR c++/52671
+// { dg-do compile }
+__attribute__ ((deprecated)) enum E { E0 };	// { dg-warning "attribute ignored in declaration of" }
+// { dg-message "must follow the" "" { target *-*-* } 3 }