be at the same address as another object, we do know it won't alias a null
pointer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143674
91177308-0d34-0410-b5e6-
96231b3b80d8
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.
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";