summaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-02-13 16:02:31 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-02-13 16:02:31 +0000
commitf0006dc2ee31cbcb3c9ea541a851c3f0ee4b9c1e (patch)
treedbb55398a6d97ba972543d45d0fd1f8e29af430a /gcc/cp/call.c
parent2d3120aee283ebd8c0f8d9206e15167fd43ac7a8 (diff)
downloadgcc-f0006dc2ee31cbcb3c9ea541a851c3f0ee4b9c1e.tar.gz
PR c++/65051
* call.c (reference_binding): Don't look for bad conversion if TO is incomplete. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@220685 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f2076c67aee..2b15185a895 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1694,6 +1694,19 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags,
difference in top-level cv-qualification is subsumed by the
initialization itself and does not constitute a conversion. */
+ /* [dcl.init.ref]
+
+ Otherwise, the reference shall be an lvalue reference to a
+ non-volatile const type, or the reference shall be an rvalue
+ reference.
+
+ We try below to treat this as a bad conversion to improve diagnostics,
+ but if TO is an incomplete class, we need to reject this conversion
+ now to avoid unnecessary instantiation. */
+ if (!CP_TYPE_CONST_NON_VOLATILE_P (to) && !TYPE_REF_IS_RVALUE (rto)
+ && !COMPLETE_TYPE_P (to))
+ return NULL;
+
/* We're generating a temporary now, but don't bind any more in the
conversion (specifically, don't slice the temporary returned by a
conversion operator). */