diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-04-18 07:57:34 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-04-18 07:57:34 +0000 |
commit | 30b5277a0abf5452709cb261bc92c8cedae3a4bc (patch) | |
tree | 7f0bbee999bb50e05045e3248e03d5aa1176a7c2 /clang/lib/Sema/SemaInit.cpp | |
parent | c9cd64eee393798c413ba20392c09c78c2a90ad5 (diff) | |
download | bcm5719-llvm-30b5277a0abf5452709cb261bc92c8cedae3a4bc.tar.gz bcm5719-llvm-30b5277a0abf5452709cb261bc92c8cedae3a4bc.zip |
When checking the copy constructor for the optional copy during a
reference binding to an rvalue of reference-compatible type, check
parameters after the first for complete parameter types and build any
required default function arguments. We're effectively simulating the
type-checking for a call without building the call itself.
llvm-svn: 101705
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 59f4393e556..7929b588b63 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -3264,10 +3264,26 @@ static Sema::OwningExprResult CopyObject(Sema &S, if (IsExtraneousCopy) { // If this is a totally extraneous copy for C++03 reference // binding purposes, just return the original initialization - // expression. + // expression. We don't generate an (elided) copy operation here + // because doing so would require us to pass down a flag to avoid + // infinite recursion, where each step adds another extraneous, + // elidable copy. + + // Instantiate the default arguments of any extra parameters in + // the selected copy constructor, as if we were going to create a + // proper call to the copy constructor. + for (unsigned I = 1, N = Constructor->getNumParams(); I != N; ++I) { + ParmVarDecl *Parm = Constructor->getParamDecl(I); + if (S.RequireCompleteType(Loc, Parm->getType(), + S.PDiag(diag::err_call_incomplete_argument))) + break; + + // Build the default argument expression; we don't actually care + // if this succeeds or not, because this routine will complain + // if there was a problem. + S.BuildCXXDefaultArgExpr(Loc, Constructor, Parm); + } - // FIXME: We'd like to call CompleteConstructorCall below, so that - // we instantiate default arguments and such. return S.Owned(CurInitExpr); } |