diff options
author | Anders Carlsson <andersca@mac.com> | 2009-09-15 06:28:28 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-09-15 06:28:28 +0000 |
commit | f6c213a931f8eedf91531f3204cc828f18466fd5 (patch) | |
tree | fefaf8b6ea47b10ee4c7b19d2385f4c53d2f5270 | |
parent | 626c2d6bc8fe57078dec2a8974994bc92ee0e1e5 (diff) |
When performing an user defined conversion sequence, perform the initial standard conversion sequence. This lets us remove a workaround in SemaCompleteConstructorCall.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81847 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 25 |
2 files changed, 21 insertions, 10 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 9e49778250..87c4e70101 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -3243,12 +3243,6 @@ Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, Expr *Arg; if (i < NumArgs) { Arg = Args[i]; - - // Pass the argument. - if (PerformCopyInitialization(Arg, ProtoArgType, "passing")) - return true; - - Args[i] = 0; } else { ParmVarDecl *Param = Constructor->getParamDecl(i); diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index a6bf82b590..a8546dd5ee 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -971,17 +971,34 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, return true; break; - case ImplicitConversionSequence::UserDefinedConversion: - { + case ImplicitConversionSequence::UserDefinedConversion: { + FunctionDecl *FD = ICS.UserDefined.ConversionFunction; CastExpr::CastKind CastKind = CastExpr::CK_Unknown; - if (isa<CXXConversionDecl>(FD)) + QualType BeforeToType; + if (const CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(FD)) { CastKind = CastExpr::CK_UserDefinedConversion; - else if (isa<CXXConstructorDecl>(FD)) + + // If the user-defined conversion is specified by a conversion function, + // the initial standard conversion sequence converts the source type to + // the implicit object parameter of the conversion function. + BeforeToType = Context.getTagDeclType(Conv->getParent()); + } else if (const CXXConstructorDecl *Ctor = + dyn_cast<CXXConstructorDecl>(FD)) { CastKind = CastExpr::CK_ConstructorConversion; + + // If the user-defined conversion is specified by a constructor, the + // initial standard conversion sequence converts the source type to the + // type required by the argument of the constructor + BeforeToType = Ctor->getParamDecl(0)->getType(); + } else assert(0 && "Unknown conversion function kind!"); + if (PerformImplicitConversion(From, BeforeToType, + ICS.UserDefined.Before, "converting")) + return true; + OwningExprResult CastArg = BuildCXXCastArgument(From->getLocStart(), ToType.getNonReferenceType(), |