C++ PATCH for c++/66748 (ICE with abi_tag on enum)

Marek Polacek polacek@redhat.com
Fri Jul 3 10:29:00 GMT 2015


The following testcase was breaking because we we're trying to
access TYPE_LANG_SPECIFIC via CLASSTYPE_TEMPLATE_* macros without
first checking that we indeed have a CLASS_TYPE.

Bootstrapped/regtested on x86_64-linux, ok for trunk/5/4.9?

2015-07-03  Marek Polacek  <polacek@redhat.com>

	PR c++/66748
	* tree.c (handle_abi_tag_attribute): Check for CLASS_TYPE_P before
	accessing TYPE_LANG_SPECIFIC node.

	* g++.dg/abi/abi-tag15.C: New test.

diff --git gcc/cp/tree.c gcc/cp/tree.c
index 0d1112c..22d5b3a 100644
--- gcc/cp/tree.c
+++ gcc/cp/tree.c
@@ -3654,13 +3654,15 @@ handle_abi_tag_attribute (tree* node, tree name, tree args,
 		 name, *node);
 	  goto fail;
 	}
-      else if (CLASSTYPE_TEMPLATE_INSTANTIATION (*node))
+      else if (CLASS_TYPE_P (*node)
+	       && CLASSTYPE_TEMPLATE_INSTANTIATION (*node))
 	{
 	  warning (OPT_Wattributes, "ignoring %qE attribute applied to "
 		   "template instantiation %qT", name, *node);
 	  goto fail;
 	}
-      else if (CLASSTYPE_TEMPLATE_SPECIALIZATION (*node))
+      else if (CLASS_TYPE_P (*node)
+	       && CLASSTYPE_TEMPLATE_SPECIALIZATION (*node))
 	{
 	  warning (OPT_Wattributes, "ignoring %qE attribute applied to "
 		   "template specialization %qT", name, *node);
diff --git gcc/testsuite/g++.dg/abi/abi-tag15.C gcc/testsuite/g++.dg/abi/abi-tag15.C
index e69de29..bfda3a2 100644
--- gcc/testsuite/g++.dg/abi/abi-tag15.C
+++ gcc/testsuite/g++.dg/abi/abi-tag15.C
@@ -0,0 +1,3 @@
+// PR c++/66748
+
+enum __attribute__((abi_tag("foo"))) E {}; // { dg-error "redeclaration of" }

	Marek



More information about the Gcc-patches mailing list