+2017-11-27 Jason Merrill <jason@redhat.com>
+
+ * pt.c (primary_template_specialization_p): Rename from
+ primary_template_instantiation_p. Don't check
+ DECL_TEMPLATE_INSTANTIATION.
+ * call.c, cp-tree.h, decl2.c: Adjust.
+
2017-11-27 Jakub Jelinek <jakub@redhat.com>
PR c++/81675
= bad_arg_conversion_rejection (NULL_TREE, -2,
rettype, totype);
}
- else if (primary_template_instantiation_p (cand->fn)
+ else if (primary_template_specialization_p (cand->fn)
&& ics->rank > cr_exact)
{
/* 13.3.3.1.2: If the user-defined conversion is specified by
/* A template instance is never a usual deallocation function,
regardless of its signature. */
if (TREE_CODE (t) == TEMPLATE_DECL
- || primary_template_instantiation_p (t))
+ || primary_template_specialization_p (t))
return false;
tree a = FUNCTION_ARG_CHAIN (t);
/* A template instance is never a usual deallocation function,
regardless of its signature. */
if (TREE_CODE (t) == TEMPLATE_DECL
- || primary_template_instantiation_p (t))
+ || primary_template_specialization_p (t))
return false;
/* If a class T has a member deallocation function named operator delete
extern void print_template_statistics (void);
bool template_template_parameter_p (const_tree);
bool template_type_parameter_p (const_tree);
-extern bool primary_template_instantiation_p (const_tree);
+extern bool primary_template_specialization_p (const_tree);
extern tree get_primary_template_innermost_parameters (const_tree);
extern tree get_template_parms_at_level (tree, int);
extern tree get_template_innermost_arguments (const_tree);
{
if (! primary_func_tmpl_inst
|| TREE_CODE (primary_func_tmpl_inst) != FUNCTION_DECL
- || ! primary_template_instantiation_p (primary_func_tmpl_inst))
+ || ! primary_template_specialization_p (primary_func_tmpl_inst))
return NULL;
return DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (primary_func_tmpl_inst));
}
/* Return true if T is a primary function, class or alias template
- instantiation. */
+ specialization, not including the template pattern. */
bool
-primary_template_instantiation_p (const_tree t)
+primary_template_specialization_p (const_tree t)
{
if (!t)
return false;
- if (TREE_CODE (t) == FUNCTION_DECL)
- return DECL_LANG_SPECIFIC (t)
- && DECL_TEMPLATE_INSTANTIATION (t)
- && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t));
+ if (TREE_CODE (t) == FUNCTION_DECL || VAR_P (t))
+ return (DECL_LANG_SPECIFIC (t)
+ && DECL_USE_TEMPLATE (t)
+ && DECL_TEMPLATE_INFO (t)
+ && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t)));
else if (CLASS_TYPE_P (t) && !TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
- return CLASSTYPE_TEMPLATE_INSTANTIATION (t)
- && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t));
+ return (CLASSTYPE_TEMPLATE_INFO (t)
+ && CLASSTYPE_USE_TEMPLATE (t)
+ && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t)));
else if (alias_template_specialization_p (t))
return true;
return false;
tree parms = NULL, template_info = NULL;
if ((template_info = get_template_info (t))
- && primary_template_instantiation_p (t))
+ && primary_template_specialization_p (t))
parms = INNERMOST_TEMPLATE_PARMS
(DECL_TEMPLATE_PARMS (TI_TEMPLATE (template_info)));
--- /dev/null
+// PR c++/46831
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+struct B { };
+struct D : B { };
+struct A {
+ template<typename T = void> operator D&(); // { dg-message "template conversion" }
+ operator long();
+};
+
+template <> A::operator D&();
+
+void f(long);
+void f(B&);
+
+struct A2 {
+ template<typename T = void> operator B&();
+};
+
+void f2(const B&);
+
+int main() {
+ f(A());
+ f2(A2());
+ f2(A()); // { dg-error "" }
+}