diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-14 03:27:21 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-14 03:27:21 +0000 |
commit | 19aeac6ea4897c542b21c9f53a0a51762d8ddf83 (patch) | |
tree | 4d445080cc4c13dc824cd5380efe18f5afac6fb0 /lib/Sema/SemaCXXCast.cpp | |
parent | f79dced038c63572965c016b969cfa870670d16e (diff) |
When type-checking a static cast (or the static_cast part of a C-style
cast) that is converting to a class type, enumerate its constructors
as in any other direct initialization. This ensures that we get the
proper conversion sequence.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88751 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXCast.cpp')
-rw-r--r-- | lib/Sema/SemaCXXCast.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index 269329543e..4d46b32c22 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -813,6 +813,19 @@ TryStaticImplicitCast(Sema &Self, Expr *SrcExpr, QualType DestType, return TC_Failed; } + if (DestType->isRecordType()) { + if (CXXConstructorDecl *Constructor + = Self.TryInitializationByConstructor(DestType, &SrcExpr, 1, + OpRange.getBegin(), + Sema::IK_Direct)) { + ConversionDecl = Constructor; + Kind = CastExpr::CK_ConstructorConversion; + return TC_Success; + } + + 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 |