summaryrefslogtreecommitdiffstats
path: root/test/Sema/outof-range-constant-compare.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema/outof-range-constant-compare.c')
-rw-r--r--test/Sema/outof-range-constant-compare.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/test/Sema/outof-range-constant-compare.c b/test/Sema/outof-range-constant-compare.c
index ccb55e4a16..36b6ff69ca 100644
--- a/test/Sema/outof-range-constant-compare.c
+++ b/test/Sema/outof-range-constant-compare.c
@@ -7,6 +7,58 @@ int main()
{
int a = value();
+ if (a == 0x0000000000000000L)
+ return 0;
+ if (a != 0x0000000000000000L)
+ return 0;
+ if (a < 0x0000000000000000L)
+ return 0;
+ if (a <= 0x0000000000000000L)
+ return 0;
+ if (a > 0x0000000000000000L)
+ return 0;
+ if (a >= 0x0000000000000000L)
+ return 0;
+
+ if (0x0000000000000000L == a)
+ return 0;
+ if (0x0000000000000000L != a)
+ return 0;
+ if (0x0000000000000000L < a)
+ return 0;
+ if (0x0000000000000000L <= a)
+ return 0;
+ if (0x0000000000000000L > a)
+ return 0;
+ if (0x0000000000000000L >= a)
+ return 0;
+
+ if (a == 0x0000000000000000UL)
+ return 0;
+ if (a != 0x0000000000000000UL)
+ return 0;
+ if (a < 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+ return 0;
+ if (a <= 0x0000000000000000UL)
+ return 0;
+ if (a > 0x0000000000000000UL)
+ return 0;
+ if (a >= 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
+ return 0;
+
+ if (0x0000000000000000UL == a)
+ return 0;
+ if (0x0000000000000000UL != a)
+ return 0;
+ if (0x0000000000000000UL < a)
+ return 0;
+ if (0x0000000000000000UL <= a) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
+ return 0;
+ if (0x0000000000000000UL > a) // expected-warning {{comparison of 0 > unsigned expression is always false}}
+ return 0;
+ if (0x0000000000000000UL >= a)
+ return 0;
+
if (a == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
return 0;
if (a != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
@@ -103,6 +155,113 @@ int main()
if (0x1234567812345678L >= l)
return 0;
+ unsigned un = 0;
+ if (un == 0x0000000000000000L)
+ return 0;
+ if (un != 0x0000000000000000L)
+ return 0;
+ if (un < 0x0000000000000000L) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+ return 0;
+ if (un <= 0x0000000000000000L)
+ return 0;
+ if (un > 0x0000000000000000L)
+ return 0;
+ if (un >= 0x0000000000000000L) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
+ return 0;
+
+ if (0x0000000000000000L == un)
+ return 0;
+ if (0x0000000000000000L != un)
+ return 0;
+ if (0x0000000000000000L < un)
+ return 0;
+ if (0x0000000000000000L <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
+ return 0;
+ if (0x0000000000000000L > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
+ return 0;
+ if (0x0000000000000000L >= un)
+ return 0;
+
+ if (un == 0x0000000000000000UL)
+ return 0;
+ if (un != 0x0000000000000000UL)
+ return 0;
+ if (un < 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+ return 0;
+ if (un <= 0x0000000000000000UL)
+ return 0;
+ if (un > 0x0000000000000000UL)
+ return 0;
+ if (un >= 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
+ return 0;
+
+ if (0x0000000000000000UL == un)
+ return 0;
+ if (0x0000000000000000UL != un)
+ return 0;
+ if (0x0000000000000000UL < un)
+ return 0;
+ if (0x0000000000000000UL <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
+ return 0;
+ if (0x0000000000000000UL > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
+ return 0;
+ if (0x0000000000000000UL >= un)
+ return 0;
+
+ float fl = 0;
+ if (fl == 0x0000000000000000L)
+ return 0;
+ if (fl != 0x0000000000000000L)
+ return 0;
+ if (fl < 0x0000000000000000L)
+ return 0;
+ if (fl <= 0x0000000000000000L)
+ return 0;
+ if (fl > 0x0000000000000000L)
+ return 0;
+ if (fl >= 0x0000000000000000L)
+ return 0;
+
+ if (0x0000000000000000L == fl)
+ return 0;
+ if (0x0000000000000000L != fl)
+ return 0;
+ if (0x0000000000000000L < fl)
+ return 0;
+ if (0x0000000000000000L <= fl)
+ return 0;
+ if (0x0000000000000000L > fl)
+ return 0;
+ if (0x0000000000000000L >= fl)
+ return 0;
+
+ double dl = 0;
+ if (dl == 0x0000000000000000L)
+ return 0;
+ if (dl != 0x0000000000000000L)
+ return 0;
+ if (dl < 0x0000000000000000L)
+ return 0;
+ if (dl <= 0x0000000000000000L)
+ return 0;
+ if (dl > 0x0000000000000000L)
+ return 0;
+ if (dl >= 0x0000000000000000L)
+ return 0;
+
+ if (0x0000000000000000L == dl)
+ return 0;
+ if (0x0000000000000000L != dl)
+ return 0;
+ if (0x0000000000000000L < dl)
+ return 0;
+ if (0x0000000000000000L <= dl)
+ return 0;
+ if (0x0000000000000000L > dl)
+ return 0;
+ if (0x0000000000000000L >= dl)
+ return 0;
+
enum E {
yes,
no,