From c203334d6d4d5e2563d90deb06f7c59bf150f00c Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 3 Dec 2002 12:29:43 -0500 Subject: [PATCH] call.c (build_user_type_conversion_1): Don't set ICS_BAD_FLAG on an ambiguous conversion. * call.c (build_user_type_conversion_1): Don't set ICS_BAD_FLAG on an ambiguous conversion. From-SVN: r59775 --- gcc/cp/ChangeLog | 5 ++++ gcc/cp/call.c | 3 ++- gcc/testsuite/g++.dg/overload/ambig1.C | 23 +++++++++++++++++++ .../g++.old-deja/g++.benjamin/15799.C | 2 +- .../g++.old-deja/g++.bugs/900514_03.C | 6 +++-- gcc/testsuite/g++.old-deja/g++.mike/net2.C | 2 +- 6 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/overload/ambig1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2399b18e0e3..611557b9821 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2002-12-03 Jason Merrill + + * call.c (build_user_type_conversion_1): Don't set ICS_BAD_FLAG on + an ambiguous conversion. + 2002-12-03 Mark Mitchell PR c++/8688 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index a7f9a917d15..1678ed25337 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -2620,7 +2620,8 @@ build_user_type_conversion_1 (totype, expr, flags) cand = candidates; /* any one will do */ cand->second_conv = build1 (AMBIG_CONV, totype, expr); ICS_USER_FLAG (cand->second_conv) = 1; - ICS_BAD_FLAG (cand->second_conv) = 1; + /* Don't set ICS_BAD_FLAG; an ambiguous conversion is no worse than + another user-defined conversion. */ return cand; } diff --git a/gcc/testsuite/g++.dg/overload/ambig1.C b/gcc/testsuite/g++.dg/overload/ambig1.C new file mode 100644 index 00000000000..2adc78c795a --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/ambig1.C @@ -0,0 +1,23 @@ +// [over.best.ics]: For the purpose of ranking implicit conversion +// sequences as described in _over.ics.rank_, the ambiguous conversion +// sequence is treated as a user-defined sequence that is indistinguishable +// from any other user- defined conversion sequence. + +struct A +{ + A(long); + A(char); +}; + +struct B +{ + B(int); +}; + +void f(A); // { dg-error "" "candidate" } +void f(B); // { dg-error "" "candidate" } + +int main() +{ + f (42); // { dg-error "ambiguous" "ambiguous" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15799.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15799.C index 5309daf8c63..01a06b042d5 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/15799.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15799.C @@ -15,7 +15,7 @@ typedef unsigned long uint_32; class sanjose { public: sanjose(); - sanjose(const sanjose&); + sanjose(const sanjose&); // ERROR - candidate sanjose(int_8 value); // ERROR - // ERROR - sanjose(uint_32 value); // ERROR - // ERROR - }; diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C index 7c4089a1bbf..370a4603c17 100644 --- a/gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C @@ -7,13 +7,15 @@ // the explicit cast syntax disambiguates the constructor as one which // invokes the type conversion operator rather than the conversion. +// NO, IT DOESN'T. It's still ambiguous. --jason 2002-12-03 + // cfront 2.0 passes this test. // keywords: user-defined type conversion operator, constructor struct t_0_st_0; -struct t_0_st_1 { // ERROR - +struct t_0_st_1 { int member; t_0_st_1 (t_0_st_0&);// ERROR - @@ -80,7 +82,7 @@ void t_1_local_init () struct t_2_st_0; -struct t_2_st_1 { // ERROR - candidate +struct t_2_st_1 { int member; t_2_st_1 (t_2_st_0); // ERROR - candidate diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net2.C b/gcc/testsuite/g++.old-deja/g++.mike/net2.C index ffc14ef2115..e525130c00f 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/net2.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/net2.C @@ -3,7 +3,7 @@ class B; -class A { +class A { // ERROR - copy ctor candidate private: A(B *); // ERROR - public: