diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp --- a/clang/lib/AST/Type.cpp +++ b/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(CanonicalType)->getElementType() ->isIncompleteType(Def); case IncompleteArray: diff --git a/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp b/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp --- a/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp +++ b/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}} +} +}