diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-20 22:12:02 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-20 22:12:02 +0000 |
commit | 72a43bbf6802c8fcfd04dcb2be8eafcb0b8fe29c (patch) | |
tree | 373619b86f05d7d267588ba1cd1b88f1a5351c88 /lib/Sema/SemaInit.cpp | |
parent | 0f602ded589d381c6c3862eae87620d19fd10f47 (diff) |
Add a new failure kind, FK_Incomplete, to InitializationSequence, to
capture failures when we try to initialize an incomplete
type. Previously, we would (ab)use FK_ConversionFailed, then
occasionally dereference a null pointer when trying to diagnose the
failure. Fixes <rdar://problem/7959007>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104286 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index c6a8b3595a..20f0c79c48 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -2054,6 +2054,7 @@ bool InitializationSequence::isAmbiguous() const { case FK_ReferenceBindingToInitList: case FK_InitListBadDestinationType: case FK_DefaultInitOfConst: + case FK_Incomplete: return false; case FK_ReferenceInitOverloadFailed: @@ -2649,7 +2650,7 @@ static void TryConstructorInitialization(Sema &S, // The type we're constructing needs to be complete. if (S.RequireCompleteType(Kind.getLocation(), DestType, 0)) { - Sequence.SetFailed(InitializationSequence::FK_ConversionFailed); + Sequence.SetFailed(InitializationSequence::FK_Incomplete); return; } @@ -4137,6 +4138,11 @@ bool InitializationSequence::Diagnose(Sema &S, << DestType << (bool)DestType->getAs<RecordType>(); } break; + + case FK_Incomplete: + S.RequireCompleteType(Kind.getLocation(), DestType, + diag::err_init_incomplete_type); + break; } PrintInitLocationNote(S, Entity); @@ -4215,6 +4221,10 @@ void InitializationSequence::dump(llvm::raw_ostream &OS) const { case FK_DefaultInitOfConst: OS << "default initialization of a const variable"; break; + + case FK_Incomplete: + OS << "initialization of incomplete type"; + break; } OS << '\n'; return; |