aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCXXCast.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-16 19:30:02 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-16 19:30:02 +0000
commitf0e43e5c4634870b8ac7bf65d5ffa5f292d4c8a5 (patch)
tree7457722861d80cfc109b40a3cc3c1d6c81de0774 /lib/Sema/SemaCXXCast.cpp
parent0ade808e0ac411baa2dbc1f76ad352b9b6d6d3f8 (diff)
Switch the checking of implicit casts for static_cast, C-style, and
functional casts over to InitializationSequence, eliminating a caller of Sema::TryImplicitConversion. We also get access and ambiguity checking "for free". More cleanups to come in this routine. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101526 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXCast.cpp')
-rw-r--r--lib/Sema/SemaCXXCast.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp
index a40bb62b17..716e51b7dd 100644
--- a/lib/Sema/SemaCXXCast.cpp
+++ b/lib/Sema/SemaCXXCast.cpp
@@ -953,26 +953,24 @@ TryStaticImplicitCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
return TC_NotApplicable;
}
- // FIXME: To get a proper error from invalid conversions here, we need to
- // reimplement more of this.
- // FIXME: This does not actually perform the conversion, and thus does not
- // check for ambiguity or access.
- ImplicitConversionSequence ICS =
- Self.TryImplicitConversion(SrcExpr, DestType,
- /*SuppressUserConversions=*/false,
- /*AllowExplicit=*/true,
- /*InOverloadResolution=*/false,
- /*one of user provided casts*/true);
-
- if (ICS.isBad())
+ InitializedEntity Entity = InitializedEntity::InitializeTemporary(DestType);
+ InitializationKind InitKind
+ = InitializationKind::CreateCast(/*FIXME:*/OpRange, CStyle);
+ InitializationSequence InitSeq(Self, Entity, InitKind, &SrcExpr, 1);
+ if (InitSeq.getKind() == InitializationSequence::FailedSequence)
return TC_NotApplicable;
- // The conversion is possible, so commit to it.
+ Sema::OwningExprResult Result
+ = InitSeq.Perform(Self, Entity, InitKind,
+ Action::MultiExprArg(Self, (void **)&SrcExpr, 1));
Kind = CastExpr::CK_NoOp;
- msg = 0;
- return Self.PerformImplicitConversion(SrcExpr, DestType, ICS, Sema::AA_Casting,
- /*IgnoreBaseAccess*/CStyle) ?
- TC_Failed : TC_Success;
+ if (Result.isInvalid()) {
+ msg = 0;
+ return TC_Failed;
+ }
+
+ SrcExpr = Result.takeAs<Expr>();
+ return TC_Success;
}
/// TryConstCast - See if a const_cast from source to destination is allowed,