forked from OSchip/llvm-project
Constant expression evaluation: although we don't know whether a literal will
be at the same address as another object, we do know it won't alias a null pointer. llvm-svn: 143674
This commit is contained in:
parent
9ef81066ad
commit
e9e20dd302
|
@ -1970,8 +1970,10 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
|
|||
return false;
|
||||
// It's implementation-defined whether distinct literals will have
|
||||
// distinct addresses. In clang, we do not guarantee the addresses are
|
||||
// distinct.
|
||||
if (IsLiteralLValue(LHSValue) || IsLiteralLValue(RHSValue))
|
||||
// distinct. However, we do know that the address of a literal will be
|
||||
// non-null.
|
||||
if ((IsLiteralLValue(LHSValue) || IsLiteralLValue(RHSValue)) &&
|
||||
LHSValue.Base && RHSValue.Base)
|
||||
return false;
|
||||
// We can't tell whether weak symbols will end up pointing to the same
|
||||
// object.
|
||||
|
|
|
@ -99,3 +99,6 @@ char c = ((union u)(123456)).b[0]; // expected-error {{not a compile-time consta
|
|||
extern const int weak_int __attribute__((weak));
|
||||
const int weak_int = 42;
|
||||
int weak_int_test = weak_int; // expected-error {{not a compile-time constant}}
|
||||
|
||||
int literalVsNull1 = "foo" == 0;
|
||||
int literalVsNull2 = 0 == "foo";
|
||||
|
|
Loading…
Reference in New Issue