[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Sema / string-concat.c
blob63abf100c020f0d01bb2dba2bc7c1665741ba6da
2 // RUN: %clang_cc1 -x c -Wstring-concatenation -fsyntax-only -verify %s
3 // RUN: %clang_cc1 -x c++ -Wstring-concatenation -fsyntax-only -verify %s
5 const char *missing_comma[] = {
6 "basic_filebuf",
7 "basic_ios",
8 "future",
9 "optional",
10 "packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
11 "promise", // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
12 "shared_future"
15 #ifndef __cplusplus
16 typedef __WCHAR_TYPE__ wchar_t;
17 #endif
19 const wchar_t *missing_comma_wchar[] = {
20 L"basic_filebuf",
21 L"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
22 L"promise", // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
23 L"shared_future"
26 #if __cplusplus >= 201103L
27 const char *missing_comma_u8[] = {
28 u8"basic_filebuf",
29 u8"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
30 u8"promise", // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
31 u8"shared_future"
33 #endif
35 const char *missing_comma_same_line[] = {"basic_filebuf", "basic_ios",
36 "future" "optional", // expected-note{{place parentheses around the string literal to silence warning}}
37 "packaged_task", "promise"}; // expected-warning@-1{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
39 const char *missing_comma_different_lines[] = {"basic_filebuf", "basic_ios" // expected-note{{place parentheses around the string literal to silence warning}}
40 "future", "optional", // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
41 "packaged_task", "promise"};
43 const char *missing_comma_same_line_all_literals[] = {"basic_filebuf", "future" "optional", "packaged_task"}; // expected-note{{place parentheses around the string literal to silence warning}}
44 // expected-warning@-1{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
46 char missing_comma_inner[][5] = {
47 "a",
48 "b",
49 "c" // expected-note{{place parentheses around the string literal to silence warning}}
50 "d" // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
53 const char *warn[] = { "cpll", "gpll", "hdmiphy" "usb480m" }; // expected-note{{place parentheses around the string literal to silence warning}}
54 // expected-warning@-1{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
56 const char *missing_two_commas_ignore[] = {"basic_filebuf",
57 "basic_ios"
58 "future"
59 "optional",
60 "packaged_task"};
62 #define ONE(x) x
63 #define TWO "foo"
64 const char *macro_test[] = { ONE("foo"),
65 TWO,
66 "foo" TWO // expected-note{{place parentheses around the string literal to silence warning}}
67 }; // expected-warning@-1{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
69 // Do not warn for macros.
71 #define BASIC_IOS "basic_ios"
72 #define FUTURE "future"
73 const char *macro_test2[] = {"basic_filebuf", BASIC_IOS
74 FUTURE, "optional",
75 "packaged_task", "promise"};
77 #define FOO(xx) xx "_normal", \
78 xx "_movable",
80 const char *macro_test3[] = {"basic_filebuf",
81 "basic_ios",
82 FOO("future")
83 "optional",
84 "packaged_task"};
86 #define BAR(name) #name "_normal"
88 const char *macro_test4[] = {"basic_filebuf",
89 "basic_ios",
90 BAR(future),
91 "optional",
92 "packaged_task"};
94 #define SUPPRESS(x) x
95 const char *macro_test5[] = { SUPPRESS("foo" "bar"), "baz" };
97 typedef struct {
98 int i;
99 const char s[11];
100 } S;
102 S s = {1, "hello" "world"};
104 const char *not_warn[] = {
105 "hello"
106 "world", "test"
109 const char *not_warn2[] = {
110 "// Aaa\\\n" " Bbb\\ \n" " Ccc?" "?/\n",
111 "// Aaa\\\r\n" " Bbb\\ \r\n" " Ccc?" "?/\r\n",
112 "// Aaa\\\r" " Bbb\\ \r" " Ccc?" "?/\r"
115 const char *not_warn3[] = {
116 "// \\tparam aaa Bbb\n",
117 "// \\tparam\n"
118 "// aaa Bbb\n",
119 "// \\tparam \n"
120 "// aaa Bbb\n",
121 "// \\tparam aaa\n"
122 "// Bbb\n"
125 const char *not_warn4[] = {"title",
126 "aaaa "
127 "bbbb "
128 "cccc "
129 "ddd.",
130 "url"
133 typedef struct {
134 const char *a;
135 const char *b;
136 const char *c;
137 } A;
139 const A not_warn5 = (A){"",
142 ""};
144 #ifdef __cplusplus
145 const A not_warn6 = A{"",
148 ""};
149 #endif
151 static A not_warn7 = {"",
155 ""};
158 // Do not warn when all the elements in the initializer are concatenated together.
159 const char *all_elems_in_init_concatenated[] = {"a" "b" "c"};
161 // Warning can be supressed also by extra parentheses.
162 const char *extra_parens_to_suppress_warning[] = {
163 "basic_filebuf",
164 "basic_ios",
165 "future",
166 "optional",
167 ("packaged_task"
168 "promise"),
169 "shared_future"