forked from OSchip/llvm-project
[clang] Treat variable-length array of incomplete element type as
incomplete type. Differential Revision: https://reviews.llvm.org/D99165
This commit is contained in:
parent
8140d0ec4a
commit
cfc36bf017
|
@ -2229,10 +2229,11 @@ bool Type::isIncompleteType(NamedDecl **Def) const {
|
|||
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:
|
||||
|
|
|
@ -133,3 +133,10 @@ namespace array_addressof {
|
|||
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}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue