diff options
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx11.cpp | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 417f7931df4..ad36e76bea4 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -1426,7 +1426,9 @@ static bool isZeroSized(const LValue &Value) { const ValueDecl *Decl = GetLValueBaseDecl(Value); if (Decl && isa<VarDecl>(Decl)) { QualType Ty = Decl->getType(); - return Ty->isIncompleteType() || Decl->getASTContext().getTypeSize(Ty) == 0; + if (Ty->isArrayType()) + return Ty->isIncompleteType() || + Decl->getASTContext().getTypeSize(Ty) == 0; } return false; } diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp index cf317950c77..dbb1255ef1c 100644 --- a/clang/test/SemaCXX/constant-expression-cxx11.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp @@ -1960,6 +1960,7 @@ namespace PR21786 { extern void (*start[])(); extern void (*end[])(); static_assert(&start != &end, ""); // expected-error {{constant expression}} + static_assert(&start != nullptr, ""); struct Foo; struct Bar { @@ -1967,7 +1968,7 @@ namespace PR21786 { static const Foo y; }; static_assert(&Bar::x != nullptr, ""); - static_assert(&Bar::x != &Bar::y, ""); // expected-error {{constant expression}} + static_assert(&Bar::x != &Bar::y, ""); } namespace PR21859 { |