AST: Limit zero-sized constexpr behavior to array types
Restricting this "extension" to array types maximizes our standards conformance while not miscompiling real-world programs. llvm-svn: 224215
This commit is contained in:
parent
0b23c37413
commit
8c92b87cd0
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue