diff options
author | Marek Polacek <mpolacek@gcc.gnu.org> | 2018-09-05 21:17:47 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2018-09-05 21:17:47 +0000 |
commit | 62c21ceea64291317650258921c34dea79b1e96b (patch) | |
tree | fd16f085a85e12e1a1f4de48c05682914012a593 /gcc/cp | |
parent | f6b95f78f8048e2fe726b6caf91d606f36f4d8c4 (diff) | |
download | gcc-62c21ceea64291317650258921c34dea79b1e96b.zip gcc-62c21ceea64291317650258921c34dea79b1e96b.tar.gz gcc-62c21ceea64291317650258921c34dea79b1e96b.tar.bz2 |
PR c++/87109, wrong overload with ref-qualifiers.
* call.c (build_user_type_conversion_1): Use NULL instead of 0. Bail
out if performing the maybe-rvalue overload resolution and a conversion
function is getting called.
* g++.dg/cpp0x/ref-qual19.C: New test.
From-SVN: r264132
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/call.c | 8 |
2 files changed, 15 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 498b1fa..b4ec9f4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,4 +1,11 @@ -2018-09-05 Pádraig Brady p@draigbrady.com +2018-09-05 Marek Polacek <polacek@redhat.com> + + PR c++/87109, wrong overload with ref-qualifiers. + * call.c (build_user_type_conversion_1): Use NULL instead of 0. Bail + out if performing the maybe-rvalue overload resolution and a conversion + function is getting called. + +2018-09-05 Pádraig Brady <p@draigbrady.com> PR c++/87185 * lambda.c (prune_lambda_captures): Protect against const_vars.get diff --git a/gcc/cp/call.c b/gcc/cp/call.c index a156702..942b2c2 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3971,7 +3971,7 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags, } cand = tourney (candidates, complain); - if (cand == 0) + if (cand == NULL) { if (complain & tf_error) { @@ -4014,6 +4014,12 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags, if (cand->viable == -1) conv->bad_p = true; + /* We're performing the maybe-rvalue overload resolution and + a conversion function is in play. This isn't going to work + because we would not end up with a suitable constructor. */ + if ((flags & LOOKUP_PREFER_RVALUE) && !DECL_CONSTRUCTOR_P (cand->fn)) + return NULL; + /* Remember that this was a list-initialization. */ if (flags & LOOKUP_NO_NARROWING) conv->check_narrowing = true; |