xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/warn-string-conversion.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -verify -fsyntax-only -Wstring-conversion %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc #define assert(EXPR) (void)(EXPR);
4*0a6a1f1dSLionel Sambuc 
5*0a6a1f1dSLionel Sambuc // Expection for common assert form.
test1()6*0a6a1f1dSLionel Sambuc void test1() {
7*0a6a1f1dSLionel Sambuc   assert(0 && "foo");
8*0a6a1f1dSLionel Sambuc   assert("foo" && 0);
9*0a6a1f1dSLionel Sambuc   assert(0 || "foo"); // expected-warning {{string literal}}
10*0a6a1f1dSLionel Sambuc }
11*0a6a1f1dSLionel Sambuc 
test2()12*0a6a1f1dSLionel Sambuc void test2() {
13*0a6a1f1dSLionel Sambuc   if ("hi") {}           // expected-warning {{string literal}}
14*0a6a1f1dSLionel Sambuc   while ("hello") {}     // expected-warning {{string literal}}
15*0a6a1f1dSLionel Sambuc   for (;"howdy";) {}     // expected-warning {{string literal}}
16*0a6a1f1dSLionel Sambuc   do { } while ("hey");  // expected-warning {{string literal}}
17*0a6a1f1dSLionel Sambuc }
18