diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-01-13 05:10:00 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-01-13 05:10:00 +0000 |
commit | 518fda1d121dcba3ad7276f5e9a94f733f6e5ecd (patch) | |
tree | e878d16963f64880e8bb29b5560ee5b668241252 /lib/Sema/SemaOverload.cpp | |
parent | 11505a90aab8928e7e6e2c11b42a601801c3e899 (diff) |
Fix argument-passing bugs in a call to object
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62147 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index be1a27e5c6..c66db173eb 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -3542,25 +3542,31 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, ResultTy, RParenLoc)); delete [] MethodArgs; + // We may have default arguments. If so, we need to allocate more + // slots in the call for them. + if (NumArgs < NumArgsInProto) + TheCall->setNumArgs(NumArgsInProto + 1); + else if (NumArgs > NumArgsInProto) + NumArgsToCheck = NumArgsInProto; + // Initialize the implicit object parameter. - if (!PerformObjectArgumentInitialization(Object, Method)) + if (PerformObjectArgumentInitialization(Object, Method)) return true; TheCall->setArg(0, Object); // Check the argument types. for (unsigned i = 0; i != NumArgsToCheck; i++) { - QualType ProtoArgType = Proto->getArgType(i); - Expr *Arg; - if (i < NumArgs) + if (i < NumArgs) { Arg = Args[i]; - else + + // Pass the argument. + QualType ProtoArgType = Proto->getArgType(i); + if (PerformCopyInitialization(Arg, ProtoArgType, "passing")) + return true; + } else { Arg = new CXXDefaultArgExpr(Method->getParamDecl(i)); - QualType ArgType = Arg->getType(); - - // Pass the argument. - if (PerformCopyInitialization(Arg, ProtoArgType, "passing")) - return true; + } TheCall->setArg(i + 1, Arg); } |