2012-09-19 01:37:21 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wtautological-constant-out-of-range-compare -verify %s
|
|
|
|
// rdar://12202422
|
|
|
|
|
|
|
|
int value(void);
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int a = value();
|
2017-09-08 06:14:25 +08:00
|
|
|
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a < 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a <= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a > 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a >= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
|
|
|
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L == a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L != a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L < a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L <= a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L > a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L >= a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a == 0x1234567812345678LL) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a == -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a < -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a > -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a <= -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (a >= -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (a == 0x12345678L) // no warning
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
short s = value();
|
2012-09-21 03:36:41 +08:00
|
|
|
if (s == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (s != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (s < 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (s <= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (s > 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (s >= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
|
|
|
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L == s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L != s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L < s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L <= s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L > s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2012-09-21 03:36:41 +08:00
|
|
|
if (0x1234567812345678L >= s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
2017-09-08 06:14:25 +08:00
|
|
|
|
2012-09-19 01:37:21 +08:00
|
|
|
long l = value();
|
|
|
|
if (l == 0x1234567812345678L)
|
|
|
|
return 0;
|
|
|
|
if (l != 0x1234567812345678L)
|
|
|
|
return 0;
|
|
|
|
if (l < 0x1234567812345678L)
|
|
|
|
return 0;
|
|
|
|
if (l <= 0x1234567812345678L)
|
|
|
|
return 0;
|
|
|
|
if (l > 0x1234567812345678L)
|
|
|
|
return 0;
|
|
|
|
if (l >= 0x1234567812345678L)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (0x1234567812345678L == l)
|
|
|
|
return 0;
|
|
|
|
if (0x1234567812345678L != l)
|
|
|
|
return 0;
|
|
|
|
if (0x1234567812345678L < l)
|
|
|
|
return 0;
|
|
|
|
if (0x1234567812345678L <= l)
|
|
|
|
return 0;
|
|
|
|
if (0x1234567812345678L > l)
|
|
|
|
return 0;
|
|
|
|
if (0x1234567812345678L >= l)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
enum E {
|
|
|
|
yes,
|
|
|
|
no,
|
|
|
|
maybe
|
|
|
|
};
|
|
|
|
enum E e;
|
|
|
|
|
2012-09-21 03:36:41 +08:00
|
|
|
if (e == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'enum E' is always false}}
|
2012-09-19 01:37:21 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|