diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-05-31 05:41:42 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-05-31 05:41:42 +0000 |
commit | e54ff6cc3e479523b71e4c7eb4bd13707d84de0f (patch) | |
tree | c3508683d9859d5dfdc1b9ace8c2b4f334440225 /clang/test/Sema/exprs.c | |
parent | b3483b3d91af65619471cdbf44563e5759eef4bc (diff) | |
download | bcm5719-llvm-e54ff6cc3e479523b71e4c7eb4bd13707d84de0f.tar.gz bcm5719-llvm-e54ff6cc3e479523b71e4c7eb4bd13707d84de0f.zip |
Expand the coverage of the warning for constants on the RHS of logical operands:
return f() || -1;
where the user meant to write '|'.
This bootstraps without any additional warnings.
Patch by Richard Trieu.
llvm-svn: 132327
Diffstat (limited to 'clang/test/Sema/exprs.c')
-rw-r--r-- | clang/test/Sema/exprs.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c index e4eeaec05d9..9ce1481f16c 100644 --- a/clang/test/Sema/exprs.c +++ b/clang/test/Sema/exprs.c @@ -189,6 +189,24 @@ int test20(int x) { // no warning, this is an idiom for "true" in old C style. return x && (signed char)1; + + return x || 0; + return x || 1; + return x || -1; // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}} + return x || 5; // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}} + return x && 0; + return x && 1; + return x && -1; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}} + return x && 5; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}} + return x || (0); + return x || (1); + return x || (-1); // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}} + return x || (5); // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}} + return x && (0); + return x && (1); + return x && (-1); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}} + return x && (5); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}} + } struct Test21; // expected-note 2 {{forward declaration}} |