2014-11-07 Jason Merrill <jason@redhat.com>
+ DR 1558
+ * pt.c (dependent_alias_template_spec_p): New.
+ (dependent_type_p_r): Handle dependent alias template specialization.
+ (template_args_equal): A dependent alias template specializations
+ is not equal to its underlying type as a template argument.
+ * tree.c (strip_typedefs): Don't strip a dependent alias
+ template-id.
+
* parser.c (cp_parser_unqualified_id): Handle __func__ here.
(cp_parser_primary_expression): Not here.
extern tree fold_non_dependent_expr_sfinae (tree, tsubst_flags_t);
extern bool alias_type_or_template_p (tree);
extern bool alias_template_specialization_p (const_tree);
+extern bool dependent_alias_template_spec_p (const_tree);
extern bool explicit_class_specialization_p (tree);
extern bool push_tinst_level (tree);
extern bool push_tinst_level_loc (tree, location_t);
|| DECL_ALIAS_TEMPLATE_P (t));
}
-/* Return TRUE iff is a specialization of an alias template. */
+/* Return TRUE iff T is a specialization of an alias template. */
bool
alias_template_specialization_p (const_tree t)
&& DECL_ALIAS_TEMPLATE_P (TYPE_TI_TEMPLATE (t)));
}
+/* Return TRUE iff T is a specialization of an alias template with
+ dependent template-arguments. */
+
+bool
+dependent_alias_template_spec_p (const_tree t)
+{
+ return (alias_template_specialization_p (t)
+ && any_dependent_template_arguments_p (TYPE_TI_ARGS (t)));
+}
+
/* Return the number of innermost template parameters in TMPL. */
static int
return template_args_equal (ot, nt);
}
else if (TYPE_P (nt))
- return TYPE_P (ot) && same_type_p (ot, nt);
+ {
+ if (!TYPE_P (ot))
+ return false;
+ /* Don't treat an alias template specialization with dependent
+ arguments as equivalent to its underlying type when used as a
+ template argument; we need them to hash differently. */
+ bool ndep = dependent_alias_template_spec_p (nt);
+ ++processing_template_decl;
+ bool odep = dependent_alias_template_spec_p (ot);
+ --processing_template_decl;
+ if (ndep != odep)
+ return false;
+ else if (ndep)
+ return (TYPE_TI_TEMPLATE (nt) == TYPE_TI_TEMPLATE (ot)
+ && template_args_equal (TYPE_TI_ARGS (nt), TYPE_TI_ARGS (ot)));
+ else
+ return same_type_p (ot, nt);
+ }
else if (TREE_CODE (ot) == TREE_VEC || TYPE_P (ot))
return 0;
else
if (TREE_CODE (type) == TYPENAME_TYPE)
return true;
/* -- a cv-qualified type where the cv-unqualified type is
- dependent. */
- type = TYPE_MAIN_VARIANT (type);
+ dependent.
+ No code is necessary for this bullet; the code below handles
+ cv-qualified types, and we don't want to strip aliases with
+ TYPE_MAIN_VARIANT because of DR 1558. */
/* -- a compound type constructed from any dependent type. */
if (TYPE_PTRMEM_P (type))
return (dependent_type_p (TYPE_PTRMEM_CLASS_TYPE (type))
return true;
/* ... or any of the template arguments is a dependent type or
an expression that is type-dependent or value-dependent. */
- else if (CLASS_TYPE_P (type) && CLASSTYPE_TEMPLATE_INFO (type)
+ else if (TYPE_TEMPLATE_INFO (type)
&& (any_dependent_template_arguments_p
- (INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (type)))))
+ (INNERMOST_TEMPLATE_ARGS (TYPE_TI_ARGS (type)))))
return true;
/* All TYPEOF_TYPEs, DECLTYPE_TYPEs, and UNDERLYING_TYPEs are