diff options
| author | Richard Trieu <rtrieu@google.com> | 2014-11-19 06:08:18 +0000 |
|---|---|---|
| committer | Richard Trieu <rtrieu@google.com> | 2014-11-19 06:08:18 +0000 |
| commit | 791b86ec55a71659cbddc3bbaaf495c699872ddf (patch) | |
| tree | dc711812cf4e6fbb29ef1939516da3dfcaa6a0d4 /clang/test/Sema | |
| parent | f552996fb397558dfccdcd9b2b8c62d608663265 (diff) | |
| download | bcm5719-llvm-791b86ec55a71659cbddc3bbaaf495c699872ddf.tar.gz bcm5719-llvm-791b86ec55a71659cbddc3bbaaf495c699872ddf.zip | |
Add the exception for strings in logical and expressions to -Wstring-conversion
for C code.
llvm-svn: 222327
Diffstat (limited to 'clang/test/Sema')
| -rw-r--r-- | clang/test/Sema/warn-string-conversion.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/Sema/warn-string-conversion.c b/clang/test/Sema/warn-string-conversion.c new file mode 100644 index 00000000000..708dd543e40 --- /dev/null +++ b/clang/test/Sema/warn-string-conversion.c @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -verify -fsyntax-only -Wstring-conversion %s + +#define assert(EXPR) (void)(EXPR); + +// Expection for common assert form. +void test1() { + assert(0 && "foo"); + assert("foo" && 0); + assert(0 || "foo"); // expected-warning {{string literal}} +} + +void test2() { + if ("hi") {} // expected-warning {{string literal}} + while ("hello") {} // expected-warning {{string literal}} + for (;"howdy";) {} // expected-warning {{string literal}} + do { } while ("hey"); // expected-warning {{string literal}} +} |

