summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaCXXCast.cpp17
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp7
2 files changed, 8 insertions, 16 deletions
diff --git a/clang/lib/Sema/SemaCXXCast.cpp b/clang/lib/Sema/SemaCXXCast.cpp
index b07635779bd..b528cc421fe 100644
--- a/clang/lib/Sema/SemaCXXCast.cpp
+++ b/clang/lib/Sema/SemaCXXCast.cpp
@@ -776,17 +776,6 @@ TryStaticImplicitCast(Sema &Self, Expr *SrcExpr, QualType DestType,
msg = 0;
return TC_Failed;
}
- if (DestType->isRecordType()) {
- // There are no further possibilities for the target type being a class,
- // neither in static_cast nor in a C-style cast. So we can fail here.
- if ((ConversionDecl =
- Self.PerformInitializationByConstructor(DestType, &SrcExpr, 1,
- OpRange.getBegin(), OpRange, DeclarationName(), Sema::IK_Direct)))
- return TC_Success;
- // The function already emitted an error.
- msg = 0;
- return TC_Failed;
- }
// FIXME: To get a proper error from invalid conversions here, we need to
// reimplement more of this.
@@ -799,9 +788,9 @@ TryStaticImplicitCast(Sema &Self, Expr *SrcExpr, QualType DestType,
/*ForceRValue=*/false);
if (ICS.ConversionKind == ImplicitConversionSequence::UserDefinedConversion)
- if (CXXConversionDecl *CV =
- dyn_cast<CXXConversionDecl>(ICS.UserDefined.ConversionFunction))
- ConversionDecl = CV;
+ if (CXXMethodDecl *MD =
+ dyn_cast<CXXMethodDecl>(ICS.UserDefined.ConversionFunction))
+ ConversionDecl = MD;
return ICS.ConversionKind == ImplicitConversionSequence::BadConversion ?
TC_NotApplicable : TC_Success;
}
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index cdda6ab32ff..061ac8d2c33 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -228,12 +228,15 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
if (CheckCastTypes(TypeRange, Ty, Exprs[0], Kind, ConversionDecl,
/*functional-style*/true))
return ExprError();
- exprs.release();
- return Owned(new (Context) CXXFunctionalCastExpr(Ty.getNonReferenceType(),
+ // We done't build this AST for X(i) where we are constructing an object.
+ if (!ConversionDecl || !isa<CXXConstructorDecl>(ConversionDecl)) {
+ exprs.release();
+ return Owned(new (Context) CXXFunctionalCastExpr(Ty.getNonReferenceType(),
Ty, TyBeginLoc,
CastExpr::CK_UserDefinedConversion,
Exprs[0], ConversionDecl,
RParenLoc));
+ }
}
if (const RecordType *RT = Ty->getAs<RecordType>()) {
OpenPOWER on IntegriCloud