summaryrefslogtreecommitdiffstats
path: root/test/Sema/compare.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema/compare.c')
-rw-r--r--test/Sema/compare.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index b2c3563..5221b17 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -288,3 +288,27 @@ int test6(unsigned i, unsigned power) {
unsigned x = (i < (1 << power) ? i : 0);
return x != 3 ? 1 << power : i;
}
+
+// <rdar://problem/8414119> enum >= (enum)0 comparison should not generate any warnings
+enum rdar8414119_Vals { X, Y, Z };
+#define ZERO 0
+#define CHECK(x) (x >= X)
+void rdar8414119_foo(enum rdar8414119_Vals v) {
+ if (CHECK(v)) // no-warning
+ return;
+ if (v >= X) // no-warning
+ return;
+}
+int rdar8414119_bar(unsigned x) {
+ return x >= ZERO; // no-warning
+}
+#undef ZERO
+#undef CHECK
+
+int rdar8511238() {
+ enum A { A_foo, A_bar };
+ enum A a;
+ if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+ return 0;
+ return 20;
+}
OpenPOWER on IntegriCloud