summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/conditional-expr.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
commitcc7e5bff5c8095fe431327724d227f11b7fb0150 (patch)
tree4e41052cfa7cda39c0b57ce7c7d89da70499ca25 /clang/test/Sema/conditional-expr.c
parent9aa35bed4584d99347843a45e7209e46c1829412 (diff)
downloadbcm5719-llvm-cc7e5bff5c8095fe431327724d227f11b7fb0150.tar.gz
bcm5719-llvm-cc7e5bff5c8095fe431327724d227f11b7fb0150.zip
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. llvm-svn: 103174
Diffstat (limited to 'clang/test/Sema/conditional-expr.c')
-rw-r--r--clang/test/Sema/conditional-expr.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/test/Sema/conditional-expr.c b/clang/test/Sema/conditional-expr.c
index 5e2c1a46248..6e248bc3cfe 100644
--- a/clang/test/Sema/conditional-expr.c
+++ b/clang/test/Sema/conditional-expr.c
@@ -52,7 +52,9 @@ void foo() {
enum Enum { EVal };
test0 = test0 ? EVal : test0;
test0 = test0 ? EVal : (int) test0; // okay: EVal is an int
- test0 = test0 ? (unsigned) EVal : (int) test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? // expected-warning {{operands of ? are integers of different signs}}
+ (unsigned) EVal
+ : (int) test0;
}
int Postgresql() {
@@ -68,3 +70,8 @@ int f0(int a) {
// GCC considers this a warning.
return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *' from a function with result type 'int'}}
}
+
+int f2(int x) {
+ // We can suppress this because the immediate context wants an int.
+ return (x != 0) ? 0U : x;
+}
OpenPOWER on IntegriCloud