re PR c++/42260 (ICE looking up template conversion operator)

Fix PR c++/42260

gcc/cp/ChangeLog:
	PR c++/42260
	* cp-tree.h (lookup_conversions): Add new bool parameter to
	declaration.
	* search.c (lookup_conversion): Use new bool parameter in
	definition.
	* call.c (add_builtin_candidates): Don't lookup template conversion
	(convert_class_to_reference, build_user_type_conversion_1,
	 build_op_call): Adjust.
	* cvt.c (build_expr_type_conversion): Likewise

gcc/testsuite/ChangeLog:
	PR c++/42260
	* conversion/cast2.C: New test.

From-SVN: r155415
This commit is contained in:
Dodji Seketeli 2009-12-23 00:31:33 +00:00 committed by Dodji Seketeli
parent 79e2daa9a1
commit 58326a5620
7 changed files with 46 additions and 8 deletions

View File

@ -1,3 +1,15 @@
2009-12-23 Dodji Seketeli <dodji@redhat.com>
PR c++/42260
* cp-tree.h (lookup_conversions): Add new bool parameter to
declaration.
* search.c (lookup_conversion): Use new bool parameter in
definition.
* call.c (add_builtin_candidates): Don't lookup template conversion
(convert_class_to_reference, build_user_type_conversion_1,
build_op_call): Adjust.
* cvt.c (build_expr_type_conversion): Likewise
2009-12-22 Jason Merrill <jason@redhat.com>
PR c++/42466

View File

@ -1009,7 +1009,7 @@ convert_class_to_reference (tree reference_type, tree s, tree expr, int flags)
struct z_candidate *cand;
bool any_viable_p;
conversions = lookup_conversions (s);
conversions = lookup_conversions (s, /*lookup_template_convs_p=*/true);
if (!conversions)
return NULL;
@ -2362,7 +2362,8 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code,
if (i == 0 && code == MODIFY_EXPR && code2 == NOP_EXPR)
return;
convs = lookup_conversions (argtypes[i]);
convs = lookup_conversions (argtypes[i],
/*lookup_template_convs_p=*/false);
if (code == COND_EXPR)
{
@ -2851,7 +2852,8 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags)
reference to it)... */
}
else
conv_fns = lookup_conversions (fromtype);
conv_fns = lookup_conversions (fromtype,
/*lookup_template_convs_p=*/true);
}
candidates = 0;
@ -3399,7 +3401,7 @@ build_op_call (tree obj, VEC(tree,gc) **args, tsubst_flags_t complain)
if (LAMBDA_TYPE_P (type))
convs = NULL_TREE;
else
convs = lookup_conversions (type);
convs = lookup_conversions (type, /*lookup_template_convs_p=*/true);
for (; convs; convs = TREE_CHAIN (convs))
{

View File

@ -4989,7 +4989,7 @@ extern int at_function_scope_p (void);
extern bool at_class_scope_p (void);
extern bool at_namespace_scope_p (void);
extern tree context_for_name_lookup (tree);
extern tree lookup_conversions (tree);
extern tree lookup_conversions (tree, bool);
extern tree binfo_from_vbase (tree);
extern tree binfo_for_vbase (tree, tree);
extern tree look_for_overrides_here (tree, tree);

View File

@ -1196,7 +1196,9 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
if (!TYPE_HAS_CONVERSION (basetype))
return NULL_TREE;
for (conv = lookup_conversions (basetype); conv; conv = TREE_CHAIN (conv))
for (conv = lookup_conversions (basetype, /*lookup_template_convs_p=*/true);
conv;
conv = TREE_CHAIN (conv))
{
int win = 0;
tree candidate;

View File

@ -2419,10 +2419,13 @@ lookup_conversions_r (tree binfo,
functions in this node were selected. This function is effectively
performing a set of member lookups as lookup_fnfield does, but
using the type being converted to as the unique key, rather than the
field name. */
field name.
If LOOKUP_TEMPLATE_CONVS_P is TRUE, the returned TREE_LIST contains
the non-hidden user-defined template conversion functions too. */
tree
lookup_conversions (tree type)
lookup_conversions (tree type,
bool lookup_template_convs_p)
{
tree convs, tpl_convs;
tree list = NULL_TREE;
@ -2449,6 +2452,9 @@ lookup_conversions (tree type)
}
}
if (lookup_template_convs_p == false)
tpl_convs = NULL_TREE;
for (; tpl_convs; tpl_convs = TREE_CHAIN (tpl_convs))
{
tree probe, next;

View File

@ -1,3 +1,8 @@
2009-12-23 Dodji Seketeli <dodji@redhat.com>
PR c++/42260
* conversion/cast2.C: New test.
2009-12-22 Jason Merrill <jason@redhat.com>
PR c++/42466

View File

@ -0,0 +1,11 @@
// Contributed by Dodji Seketeli <dodji@redhat.com>
// Origin: PR c++/42260
// { dg-do compile }
struct A
{
template<typename T> operator T*();
};
int i = *A();// { dg-error "no match" }