static bool isZeroSized(const LValue &Value) {
const ValueDecl *Decl = GetLValueBaseDecl(Value);
- return Decl && isa<VarDecl>(Decl) &&
- Decl->getASTContext().getTypeSize(Decl->getType()) == 0;
+ if (Decl && isa<VarDecl>(Decl)) {
+ QualType Ty = Decl->getType();
+ return Ty->isIncompleteType() || Decl->getASTContext().getTypeSize(Ty) == 0;
+ }
+ return false;
}
static bool EvalPointerValueAsBool(const APValue &Value, bool &Result) {
return Error(E);
// We can't tell whether an object is at the same address as another
// zero sized object.
- if (isZeroSized(LHSValue) || isZeroSized(RHSValue))
+ if ((RHSValue.Base && isZeroSized(LHSValue)) ||
+ (LHSValue.Base && isZeroSized(RHSValue)))
return Error(E);
// Pointers with different bases cannot represent the same object.
// (Note that clang defaults to -fmerge-all-constants, which can
extern void (*start[])();
extern void (*end[])();
static_assert(&start != &end, ""); // expected-error {{constant expression}}
+
+ struct Foo;
+ struct Bar {
+ static const Foo x;
+ static const Foo y;
+ };
+ static_assert(&Bar::x != nullptr, "");
+ static_assert(&Bar::x != &Bar::y, ""); // expected-error {{constant expression}}
}