hokein created this revision. hokein added a reviewer: sammccall. hokein requested review of this revision. Herald added a project: clang.
The LookupDestructor requires a complete class definition, the callside (checkDesturctorReference) didnt't guarantee that. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D99165 Files: clang/lib/Sema/SemaInit.cpp clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp Index: clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp =================================================================== --- clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp +++ clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp @@ -133,3 +133,11 @@ namespace PR24816 { struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in scalar initializer}} } + +namespace no_crash { +template <class T> +class Foo {}; +void test(int foo) { + Foo<int> array[foo] = {0}; // expected-error {{variable-sized object may not be initialized}} +} +} Index: clang/lib/Sema/SemaInit.cpp =================================================================== --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -1831,6 +1831,8 @@ auto *CXXRD = ElementType->getAsCXXRecordDecl(); if (!CXXRD) return false; + if (!CXXRD->isCompleteDefinition()) + return false; CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(CXXRD); SemaRef.CheckDestructorAccess(Loc, Destructor,
Index: clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp =================================================================== --- clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp +++ clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp @@ -133,3 +133,11 @@ namespace PR24816 { struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in scalar initializer}} } + +namespace no_crash { +template <class T> +class Foo {}; +void test(int foo) { + Foo<int> array[foo] = {0}; // expected-error {{variable-sized object may not be initialized}} +} +} Index: clang/lib/Sema/SemaInit.cpp =================================================================== --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -1831,6 +1831,8 @@ auto *CXXRD = ElementType->getAsCXXRecordDecl(); if (!CXXRD) return false; + if (!CXXRD->isCompleteDefinition()) + return false; CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(CXXRD); SemaRef.CheckDestructorAccess(Loc, Destructor,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits