From 086bb4b9cd0780609f150e03cad8490bb734ccd8 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 20 Feb 2011 20:50:39 -0500 Subject: re PR c++/46831 ([C++0x] Crash when it tries to do an invalid ICS with a conversion function template) PR c++/46831 * call.c (convert_class_to_reference): Don't try to set up a second conv sequence for non-viable candidates. From-SVN: r170354 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/call.c | 6 ++++-- gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 848765d..4ce3f27 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-02-20 Jason Merrill + PR c++/46831 + * call.c (convert_class_to_reference): Don't try to set up a + second conv sequence for non-viable candidates. + PR c++/47703 * error.c (location_of): Handle non-tagged types. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 7d602b9..078542a 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1230,8 +1230,10 @@ convert_class_to_reference (tree reference_type, tree s, tree expr, int flags) rvalue of the right type is good enough. */ tree f = cand->fn; tree t2 = TREE_TYPE (TREE_TYPE (f)); - if (TREE_CODE (t2) != REFERENCE_TYPE - || !reference_compatible_p (t, TREE_TYPE (t2))) + if (cand->viable == 0) + /* Don't bother looking more closely. */; + else if (TREE_CODE (t2) != REFERENCE_TYPE + || !reference_compatible_p (t, TREE_TYPE (t2))) { /* No need to set cand->reason here; this is most likely an ambiguous match. If it's not, either this candidate diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 91ef5f1..db45d88 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-02-20 Jason Merrill + * g++.dg/cpp0x/fntmpdefarg2.C: New. + * g++.dg/overload/conv-op1.C: New. * g++.dg/cpp0x/constexpr-synth1.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C new file mode 100644 index 0000000..12cc836 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C @@ -0,0 +1,14 @@ +// PR c++/46831 +// { dg-options -std=c++0x } + +struct B { }; +struct D : B { }; +struct A { + template operator D&(); + operator long(); +}; + +void f(long); +void f(B&); + +int main() { f(A()); } -- cgit v1.1