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();
|
return !Rec->isCompleteDefinition();
|
||||||
}
|
}
|
||||||
case ConstantArray:
|
case ConstantArray:
|
||||||
|
case VariableArray:
|
||||||
// An array is incomplete if its element type is incomplete
|
// An array is incomplete if its element type is incomplete
|
||||||
// (C++ [dcl.array]p1).
|
// (C++ [dcl.array]p1).
|
||||||
// We don't handle variable arrays (they're not allowed in C++) or
|
// We don't handle dependent-sized arrays (dependent types are never treated
|
||||||
// dependent-sized arrays (dependent types are never treated as incomplete).
|
// as incomplete).
|
||||||
return cast<ArrayType>(CanonicalType)->getElementType()
|
return cast<ArrayType>(CanonicalType)->getElementType()
|
||||||
->isIncompleteType(Def);
|
->isIncompleteType(Def);
|
||||||
case IncompleteArray:
|
case IncompleteArray:
|
||||||
|
|
|
@ -133,3 +133,10 @@ namespace array_addressof {
|
||||||
namespace PR24816 {
|
namespace PR24816 {
|
||||||
struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in scalar initializer}}
|
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