diff options
| author | Roman Lebedev <lebedev.ri@gmail.com> | 2017-09-20 13:50:01 +0000 |
|---|---|---|
| committer | Roman Lebedev <lebedev.ri@gmail.com> | 2017-09-20 13:50:01 +0000 |
| commit | 30d26086372cfb99b0829e676d075f95e2b9c35a (patch) | |
| tree | 699689c3e5e0d2d365a0743dbe4037429dcfa973 /clang/test/Sema/tautological-unsigned-enum-zero-compare.c | |
| parent | d202ad15c11950c71b8379ae3e2db4892b5d9d7b (diff) | |
| download | bcm5719-llvm-30d26086372cfb99b0829e676d075f95e2b9c35a.tar.gz bcm5719-llvm-30d26086372cfb99b0829e676d075f95e2b9c35a.zip | |
Replace r313747, don't always warn on enums, rework testcases.
As Aaron Ballman has pointed out, that is not really correct.
So the key problem there is the invalidity of the testcase.
Revert r313747, and rework testcase in such a way, so these
details (platform-specific default enum sigdness) are
accounted for.
Also, add a C++-specific testcase.
llvm-svn: 313756
Diffstat (limited to 'clang/test/Sema/tautological-unsigned-enum-zero-compare.c')
| -rw-r--r-- | clang/test/Sema/tautological-unsigned-enum-zero-compare.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/clang/test/Sema/tautological-unsigned-enum-zero-compare.c b/clang/test/Sema/tautological-unsigned-enum-zero-compare.c index a0c2a30055c..49982a9fd71 100644 --- a/clang/test/Sema/tautological-unsigned-enum-zero-compare.c +++ b/clang/test/Sema/tautological-unsigned-enum-zero-compare.c @@ -1,11 +1,16 @@ -// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s -// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-enum-zero-compare -verify %s +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DALL_WARN -verify %s +// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGN_WARN -verify %s +// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -Wno-tautological-unsigned-enum-zero-compare -verify %s + +// Okay, this is where it gets complicated. +// Then default enum sigdness is target-specific. +// On windows, it is signed by default. We do not want to warn in that case. int main() { enum A { A_foo, A_bar }; enum A a; -#ifdef TEST +#ifdef ALL_WARN if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} return 0; if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} @@ -22,6 +27,23 @@ int main() { return 0; if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} return 0; +#elif defined(SIGN_WARN) + if (a < 0) // ok + return 0; + if (a >= 0) // ok + return 0; + if (0 <= a) // ok + return 0; + if (0 > a) // ok + return 0; + if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} + return 0; + if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} + return 0; + if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} + return 0; + if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} + return 0; #else // expected-no-diagnostics if (a < 0) |

