diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
commit | 461a67fa15370a9ec88f8f8a240bf7c123bb2029 (patch) | |
tree | 6942083d7d56bba40ec790a453ca58ad3baf6832 /test/SemaCXX/compare.cpp | |
parent | 75c3240472ba6ac2669ee72ca67eb72d4e2851fc (diff) |
Vendor import of clang trunk r321017:vendor/clang/clang-trunk-r321017
Notes
Notes:
svn path=/vendor/clang/dist/; revision=326941
svn path=/vendor/clang/clang-trunk-r321017/; revision=326942; tag=vendor/clang/clang-trunk-r321017
Diffstat (limited to 'test/SemaCXX/compare.cpp')
-rw-r--r-- | test/SemaCXX/compare.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/test/SemaCXX/compare.cpp b/test/SemaCXX/compare.cpp index 0528b044fb1f..d852180c0663 100644 --- a/test/SemaCXX/compare.cpp +++ b/test/SemaCXX/compare.cpp @@ -73,7 +73,7 @@ int test0(long a, unsigned long b) { ((int) a == (unsigned int) B) + ((short) a == (unsigned short) B) + ((signed char) a == (unsigned char) B) + - (a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}} + (a < (unsigned long) B) + // expected-warning {{comparison of unsigned expression < 0 is always false}} (a < (unsigned int) B) + (a < (unsigned short) B) + (a < (unsigned char) B) + @@ -81,8 +81,8 @@ int test0(long a, unsigned long b) { ((int) a < B) + ((short) a < B) + ((signed char) a < B) + - ((long) a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}} - ((int) a < (unsigned int) B) + // expected-warning {{comparison of integers of different signs}} + ((long) a < (unsigned long) B) + // expected-warning {{comparison of unsigned expression < 0 is always false}} + ((int) a < (unsigned int) B) + // expected-warning {{comparison of unsigned expression < 0 is always false}} ((short) a < (unsigned short) B) + ((signed char) a < (unsigned char) B) + @@ -245,8 +245,8 @@ void test4(short s) { // unsigned. const unsigned B = -1; void (s < B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} - void (s > B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} - void (s <= B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} + void (s > B); // expected-warning{{comparison 'short' > 4294967295 is always false}} + void (s <= B); // expected-warning{{comparison 'short' <= 4294967295 is always true}} void (s >= B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} void (s == B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} void (s != B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} @@ -423,3 +423,19 @@ namespace templates { testx<B>(); } } + +namespace tautological_enum { + enum E { a, b, c } e; + + // FIXME: We should warn about constructing this out-of-range numeration value. + const E invalid = (E)-1; + // ... but we should not warn about comparing against it. + bool x = e == invalid; + + // We should not warn about relational comparisons for enumerators, even if + // they're tautological. + bool y = e >= a && e <= b; + const E first_in_range = a; + const E last_in_range = b; + bool z = e >= first_in_range && e <= last_in_range; +} |