xref: /illumos-gate/usr/src/tools/smatch/src/validation/init-char-array1.c (revision a61ed2ce7a86a4d6428f2a83eb4739fae945447e)
1 /*
2  * for array of char, ("...") as the initializer is an gcc language
3  * extension. check that a parenthesized string initializer is handled
4  * correctly and that -Wparen-string warns about it's use.
5  */
6 static const char u[] = ("hello");
7 static const char v[] = {"hello"};
8 static const char v1[] = {("hello")};
9 static const char w[] = "hello";
10 static const char x[5] = "hello";
11 
12 static void f(void)
13 {
14 	char a[1/(sizeof(u) == 6)];
15 	char b[1/(sizeof(v) == 6)];
16 	char c[1/(sizeof(w) == 6)];
17 	char d[1/(sizeof(x) == 5)];
18 }
19 /*
20  * check-name: parenthesized string initializer
21  * check-command: sparse -Wparen-string $file
22  *
23  * check-error-start
24 init-char-array1.c:6:26: warning: array initialized from parenthesized string constant
25 init-char-array1.c:8:28: warning: array initialized from parenthesized string constant
26  * check-error-end
27  */
28