diff options
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 1 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 12 | ||||
-rw-r--r-- | lib/Sema/SemaInit.h | 4 |
4 files changed, 18 insertions, 2 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 4d4ad71479..bfcf13038d 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -713,6 +713,7 @@ def note_uninit_reference_member : Note< "uninitialized reference member is here">; def warn_field_is_uninit : Warning<"field is uninitialized when used here">, InGroup<DiagGroup<"uninitialized">>; +def err_init_incomplete_type : Error<"initialization of incomplete type %0">; def err_temp_copy_no_viable : Error< "no viable constructor %select{copying variable|copying parameter|" diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index b32055a8a4..bd20526796 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1562,6 +1562,9 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, FieldDecl *Field, CXXBaseOrMemberInitializer *&CXXMemberInit) { + if (Field->isInvalidDecl()) + return true; + if (ImplicitInitKind == IIK_Copy) { SourceLocation Loc = Constructor->getLocation(); ParmVarDecl *Param = Constructor->getParamDecl(0); 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; diff --git a/lib/Sema/SemaInit.h b/lib/Sema/SemaInit.h index 35adf9e49e..a9064ede6d 100644 --- a/lib/Sema/SemaInit.h +++ b/lib/Sema/SemaInit.h @@ -544,7 +544,9 @@ public: /// \brief Overloaded for initialization by constructor failed. FK_ConstructorOverloadFailed, /// \brief Default-initialization of a 'const' object. - FK_DefaultInitOfConst + FK_DefaultInitOfConst, + /// \brief Initialization of an incomplete type. + FK_Incomplete }; private: |