aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/cp-tree.h23
2 files changed, 16 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9c5a2bc..a545511 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -41,6 +41,10 @@
2011-11-09 Dodji Seketeli <dodji@redhat.com>
+ PR c++/51043
+ * cp-tree.h (TYPE_ALIAS_P, TYPE_TEMPLATE_INFO): Don't crash on
+ NULL TYPE_NAME.
+
PR c++/51027
* parser.c (cp_parser_alias_declaration): Require ';' at the end
of the declaration.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 5ba1885..b306976 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