summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2014-01-25 01:10:35 +0000
committerRichard Trieu <rtrieu@google.com>2014-01-25 01:10:35 +0000
commit955231ddf6cbb54f0931b78eb6e9b3f18438b5d4 (patch)
tree4f0c79285018431c4b95e63c38f4bc9d352db921 /clang/test
parent6bd95b8aac4609a46fc8fb3d053f87890d047614 (diff)
downloadbcm5719-llvm-955231ddf6cbb54f0931b78eb6e9b3f18438b5d4.tar.gz
bcm5719-llvm-955231ddf6cbb54f0931b78eb6e9b3f18438b5d4.zip
Broaden -Wstring-conversion to catch string literals in logical or expressions.
Previously, string literals were ignored in all logical expressions. This reduces it to only ignore in logical and expressions. assert(0 && "error"); // No warning assert(0 || "error"); // Warn Fixes PR17565 llvm-svn: 200056
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/warn-string-conversion.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/warn-string-conversion.cpp b/clang/test/SemaCXX/warn-string-conversion.cpp
index 23960e48df6..b26126f6c72 100644
--- a/clang/test/SemaCXX/warn-string-conversion.cpp
+++ b/clang/test/SemaCXX/warn-string-conversion.cpp
@@ -1,14 +1,20 @@
// RUN: %clang_cc1 -fsyntax-only -Wstring-conversion -verify %s
// Warn on cases where a string literal is converted into a bool.
-// An exception is made for this in logical operators.
+// An exception is made for this in logical and operators.
void assert(bool condition);
void test0() {
bool b0 = "hi"; // expected-warning{{implicit conversion turns string literal into bool: 'const char [3]' to 'bool'}}
b0 = ""; // expected-warning{{implicit conversion turns string literal into bool: 'const char [1]' to 'bool'}}
+ b0 = 0 || ""; // expected-warning{{implicit conversion turns string literal into bool: 'const char [1]' to 'bool'}}
+ b0 = "" || 0; // expected-warning{{implicit conversion turns string literal into bool: 'const char [1]' to 'bool'}}
b0 = 0 && "";
+ b0 = "" && 0;
assert("error"); // expected-warning{{implicit conversion turns string literal into bool: 'const char [6]' to 'bool'}}
+ assert(0 || "error"); // expected-warning{{implicit conversion turns string literal into bool: 'const char [6]' to 'bool'}}
+ assert("error" || 0); // expected-warning{{implicit conversion turns string literal into bool: 'const char [6]' to 'bool'}}
assert(0 && "error");
+ assert("error" && 0);
while("hi") {} // expected-warning{{implicit conversion turns string literal into bool: 'const char [3]' to 'bool'}}
do {} while("hi"); // expected-warning{{implicit conversion turns string literal into bool: 'const char [3]' to 'bool'}}
OpenPOWER on IntegriCloud