1 // RUN: %clang_cc1 -verify -fsyntax-only -Wstring-conversion %s 2 3 void do_nothing(); 4 void assert_error(); 5 6 #define assert1(expr) \ 7 if (expr) \ 8 do_nothing(); \ 9 else \ 10 assert_error() 11 12 #define assert2(expr) \ 13 ((expr) ? do_nothing() : assert_error()) 14 15 // Expection for common assert form. test1()16void test1() { 17 assert1(0 && "foo"); 18 assert1("foo" && 0); 19 assert1(0 || "foo"); // expected-warning {{string literal}} 20 assert1("foo"); // expected-warning {{string literal}} 21 22 assert2(0 && "foo"); 23 assert2("foo" && 0); 24 assert2(0 || "foo"); // expected-warning {{string literal}} 25 assert2("foo"); // expected-warning {{string literal}} 26 } 27 test2()28void test2() { 29 if ("hi") {} // expected-warning {{string literal}} 30 while ("hello") {} // expected-warning {{string literal}} 31 for (;"howdy";) {} // expected-warning {{string literal}} 32 do { } while ("hey"); // expected-warning {{string literal}} 33 int x = "hey" ? 1 : 2; // expected-warning {{string literal}} 34 } 35