diff options
author | Jason Merrill <jason@redhat.com> | 2011-02-20 20:50:39 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-02-20 20:50:39 -0500 |
commit | 086bb4b9cd0780609f150e03cad8490bb734ccd8 (patch) | |
tree | 8eb16863b96940d91a2783d42f906f4031cf7dc4 /gcc | |
parent | 58b0a7004dcb4584d3708d187feecbc9bdde11e5 (diff) | |
download | gcc-086bb4b9cd0780609f150e03cad8490bb734ccd8.zip gcc-086bb4b9cd0780609f150e03cad8490bb734ccd8.tar.gz gcc-086bb4b9cd0780609f150e03cad8490bb734ccd8.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/call.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C | 14 |
4 files changed, 24 insertions, 2 deletions
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 <jason@redhat.com> + 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 <jason@redhat.com> + * 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<typename T = void> operator D&(); + operator long(); +}; + +void f(long); +void f(B&); + +int main() { f(A()); } |