[PATCH] D99165: [clang] Fix a crash on checkDestructorReference.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 24 03:31:37 PDT 2021
hokein updated this revision to Diff 332925.
hokein added a comment.
- jrefine the fix of the crash: if the element type of an variable-length array
is incomplete, the array type is incomplete;
- simplify the testcase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99165/new/
https://reviews.llvm.org/D99165
Files:
clang/lib/AST/Type.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,10 @@
namespace PR24816 {
struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in scalar initializer}}
}
+
+namespace no_crash {
+class Foo; // expected-note {{forward declaration}}
+void test(int size) {
+ Foo array[size] = {0}; // expected-error {{variable has incomplete type}}
+}
+}
Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2229,10 +2229,11 @@
return !Rec->isCompleteDefinition();
}
case ConstantArray:
+ case VariableArray:
// An array is incomplete if its element type is incomplete
// (C++ [dcl.array]p1).
- // We don't handle variable arrays (they're not allowed in C++) or
- // dependent-sized arrays (dependent types are never treated as incomplete).
+ // We don't handle dependent-sized arrays (dependent types are never treated
+ // as incomplete).
return cast<ArrayType>(CanonicalType)->getElementType()
->isIncompleteType(Def);
case IncompleteArray:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99165.332925.patch
Type: text/x-patch
Size: 1310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210324/81333362/attachment.bin>
More information about the cfe-commits
mailing list