[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / warn-string-conversion.c
blob809fbc575205515a840843306c96349d55c49510
1 // RUN: %clang_cc1 -verify -fsyntax-only -Wstring-conversion %s
3 void do_nothing(void);
4 void assert_error(void);
6 #define assert1(expr) \
7 if (expr) \
8 do_nothing(); \
9 else \
10 assert_error()
12 #define assert2(expr) \
13 ((expr) ? do_nothing() : assert_error())
15 // Exception for common assert form.
16 void test1(void) {
17 assert1(0 && "foo");
18 assert1("foo" && 0);
19 assert1(0 || "foo"); // expected-warning {{string literal}}
20 assert1("foo"); // expected-warning {{string literal}}
22 assert2(0 && "foo");
23 assert2("foo" && 0);
24 assert2(0 || "foo"); // expected-warning {{string literal}}
25 assert2("foo"); // expected-warning {{string literal}}
28 void test2(void) {
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}}