Commit c5918c21 by Jason Merrill Committed by Jason Merrill

re PR c++/58119 (Invalid ambiguous default type conversion with only a single…

re PR c++/58119 (Invalid ambiguous default type conversion with only a single invalid conversion listed.)

	PR c++/58119
	* cvt.c (build_expr_type_conversion): Don't complain about a
	template that can't match the desired type category.

From-SVN: r201880
parent f8693faf
2013-08-20 Jason Merrill <jason@redhat.com>
PR c++/58119
* cvt.c (build_expr_type_conversion): Don't complain about a
template that can't match the desired type category.
2013-08-20 Gabriel Dos Reis <gdr@integrable-solutions.net>
* error.c (pp_ggc_formatted_text): New.
......
......@@ -1590,17 +1590,6 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
if (DECL_NONCONVERTING_P (cand))
continue;
if (TREE_CODE (cand) == TEMPLATE_DECL)
{
if (complain)
{
error ("ambiguous default type conversion from %qT",
basetype);
error (" candidate conversions include %qD", cand);
}
return error_mark_node;
}
candidate = non_reference (TREE_TYPE (TREE_TYPE (cand)));
switch (TREE_CODE (candidate))
......@@ -1634,11 +1623,23 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
break;
default:
/* A wildcard could be instantiated to match any desired
type, but we can't deduce the template argument. */
if (WILDCARD_TYPE_P (candidate))
win = true;
break;
}
if (win)
{
if (TREE_CODE (cand) == TEMPLATE_DECL)
{
if (complain)
error ("default type conversion can't deduce template"
" argument for %qD", cand);
return error_mark_node;
}
if (winner)
{
tree winner_type
......
// PR c++/58119
template <class T>
struct A
{
operator T*();
template <class U>
operator A<U>();
};
template <class T>
struct B
{
operator T*();
template <class U>
operator A<U>*();
};
int main()
{
A<int> a;
delete a;
B<int> b;
delete b; // { dg-error "template|delete" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment