summaryrefslogtreecommitdiff
path: root/test/Sema/compare.c
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-05-06 08:58:33 +0000
committerJohn McCall <rjmccall@apple.com>2010-05-06 08:58:33 +0000
commit323ed74658bc8375278eabf074b4777458376540 (patch)
tree79c5ffce888a353671a67db832f8ba4c6520193d /test/Sema/compare.c
parent1b5a618c59025898806160ed5e7f0ff5bb79e482 (diff)
downloadclang-323ed74658bc8375278eabf074b4777458376540.tar.gz
Rearchitect -Wconversion and -Wsign-compare. Instead of computing them
"bottom-up" when implicit casts and comparisons are inserted, compute them "top-down" when the full expression is finished. Makes it easier to coordinate warnings and thus implement -Wconversion for signedness conversions without double-warning with -Wsign-compare. Also makes it possible to realize that a signedness conversion is okay because the context is performing the inverse conversion. Also simplifies some logic that was trying to calculate the ultimate comparison/result type and getting it wrong. Also fixes a problem with the C++ explicit casts which are often "implemented" in the AST with a series of implicit cast expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103174 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/compare.c')
-rw-r--r--test/Sema/compare.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index 631b694202..f997dc1a73 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -23,8 +23,8 @@ int ints(long a, unsigned long b) {
((signed char) a == b) + // expected-warning {{comparison of integers of different signs}}
((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}}
- ((short) a == (unsigned short) b) + // expected-warning {{comparison of integers of different signs}}
- ((signed char) a == (unsigned char) b) + // expected-warning {{comparison of integers of different signs}}
+ ((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 int) b) +
(a < (unsigned short) b) +
@@ -35,8 +35,8 @@ int ints(long a, unsigned long b) {
((signed char) a < b) + // expected-warning {{comparison of integers of different signs}}
((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}}
- ((short) a < (unsigned short) b) + // expected-warning {{comparison of integers of different signs}}
- ((signed char) a < (unsigned char) b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) b) +
+ ((signed char) a < (unsigned char) b) +
// (A,b)
(A == (unsigned long) b) +
@@ -87,8 +87,8 @@ int ints(long a, unsigned long 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}}
- ((short) a < (unsigned short) B) + // expected-warning {{comparison of integers of different signs}}
- ((signed char) a < (unsigned char) B) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) B) +
+ ((signed char) a < (unsigned char) B) +
// (C,b)
(C == (unsigned long) b) +
@@ -139,8 +139,8 @@ int ints(long a, unsigned long b) {
((signed char) a < C) +
((long) a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
((int) a < (unsigned int) C) + // expected-warning {{comparison of integers of different signs}}
- ((short) a < (unsigned short) C) + // expected-warning {{comparison of integers of different signs}}
- ((signed char) a < (unsigned char) C) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) C) +
+ ((signed char) a < (unsigned char) C) +
// (0x80000,b)
(0x80000 == (unsigned long) b) +
@@ -191,8 +191,8 @@ int ints(long a, unsigned long b) {
((signed char) a < 0x80000) +
((long) a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
((int) a < (unsigned int) 0x80000) + // expected-warning {{comparison of integers of different signs}}
- ((short) a < (unsigned short) 0x80000) + // expected-warning {{comparison of integers of different signs}}
- ((signed char) a < (unsigned char) 0x80000) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) 0x80000) +
+ ((signed char) a < (unsigned char) 0x80000) +
// We should be able to avoid warning about this.
(b != (a < 4 ? 1 : 2)) +