diff mbox

PR c++/51043 - ICE in LTO

Message ID m3y5vpfb8u.fsf@redhat.com
State New
Headers show

Commit Message

Dodji Seketeli Nov. 9, 2011, 5:37 p.m. UTC
Hello,

LTO crashes during debug info generation while seamlessly trying to
see if an anonymous union type has template info, using the
TYPE_TEMPLATE_INFO accessor.  That type's TYPE_NAME is NULL and we
TYPE_TEMPLATE_INFO shouldn't crash on that.

The first hunk (the change to TYPE_ALIAS_P) is what's strictly
necessary to fix this.  I went on to make the other part of
TYPE_TEMPLATE_INFO that uses TYPE_NAME to be robust as well, in the
second hunk.

No test is needed because this was regressing g++.dg/lto/20100423-3.C.
 
Bootstrapped and tested on powerpc64-unknown-linux-gnu against trunk.

From: Dodji Seketeli <dodji@redhat.com>
Date: Wed, 9 Nov 2011 15:58:08 +0100
Subject: [PATCH] PR c++/51043 - ICE in LTO

	* cp-tree.h (TYPE_ALIAS_P, TYPE_TEMPLATE_INFO): Don't crash on
	NULL TYPE_NAME.
---
 gcc/cp/cp-tree.h |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

Comments

Jason Merrill Nov. 9, 2011, 5:43 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 32d08ca..9410e54 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2550,8 +2550,9 @@  extern void decl_shadowed_for_var_insert (tree, tree);
 /* Nonzero for a type which is an alias for another type; i.e, a type
    which declaration was written 'using name-of-type =
    another-type'.  */
-#define TYPE_ALIAS_P(NODE) \
-  (TYPE_P (NODE) \
+#define TYPE_ALIAS_P(NODE)			\
+  (TYPE_P (NODE)				\
+   && TYPE_NAME (NODE)				\
    && TYPE_DECL_ALIAS_P (TYPE_NAME (NODE)))
 
 /* For a class type: if this structure has many fields, we'll sort them
@@ -2605,15 +2606,15 @@  extern void decl_shadowed_for_var_insert (tree, tree);
    ->template_info)
 
 /* Template information for an ENUMERAL_, RECORD_, or UNION_TYPE.  */
-#define TYPE_TEMPLATE_INFO(NODE)			\
-  (TREE_CODE (NODE) == ENUMERAL_TYPE			\
-   ? ENUM_TEMPLATE_INFO (NODE) :			\
-   (TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM	\
-    ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE) :	\
-    ((CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE))	\
-     ? CLASSTYPE_TEMPLATE_INFO (NODE)			\
-     : (DECL_LANG_SPECIFIC (TYPE_NAME (NODE))		\
-	? (DECL_TEMPLATE_INFO (TYPE_NAME (NODE)))	\
+#define TYPE_TEMPLATE_INFO(NODE)					\
+  (TREE_CODE (NODE) == ENUMERAL_TYPE					\
+   ? ENUM_TEMPLATE_INFO (NODE) :					\
+   (TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM			\
+    ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE) :			\
+    ((CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE))			\
+     ? CLASSTYPE_TEMPLATE_INFO (NODE)					\
+     : ((TYPE_NAME (NODE) && DECL_LANG_SPECIFIC (TYPE_NAME (NODE)))	\
+	? (DECL_TEMPLATE_INFO (TYPE_NAME (NODE)))			\
 	: NULL_TREE))))
 
 /* Set the template information for an ENUMERAL_, RECORD_, or