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
[] = {
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?}}
16 typedef __WCHAR_TYPE__
wchar_t;
19 const wchar_t *missing_comma_wchar
[] = {
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?}}
26 #if __cplusplus >= 201103L
27 const char *missing_comma_u8
[] = {
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?}}
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] = {
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",
64 const char *macro_test
[] = { ONE("foo"),
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
75 "packaged_task", "promise"};
77 #define FOO(xx) xx "_normal", \
80 const char *macro_test3
[] = {"basic_filebuf",
86 #define BAR(name) #name "_normal"
88 const char *macro_test4
[] = {"basic_filebuf",
95 const char *macro_test5
[] = { SUPPRESS("foo" "bar"), "baz" };
102 S s
= {1, "hello" "world"};
104 const char *not_warn
[] = {
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",
125 const char *not_warn4
[] = {"title",
139 const A not_warn5
= (A
){"",
145 const A not_warn6
= A
{"",
151 static A not_warn7
= {"",
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
[] = {