aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/warn-string-conversion.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema/warn-string-conversion.c')
-rw-r--r--test/Sema/warn-string-conversion.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/Sema/warn-string-conversion.c b/test/Sema/warn-string-conversion.c
new file mode 100644
index 000000000000..708dd543e402
--- /dev/null
+++ b/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}}
+}