22 static struct B k= {.c = 1, .d = {.a = a, .b = {1, 1}}}; // KO
23 static struct B l= {.c = 1, .d = {.a = 1, .b = {a, 1}}}; // KO
24 static struct B m= {.c = 1, .d = {.a = 1, .b = {1, a}}}; // KO
25
26 static int n[] = {a, 1}; // KO
27 static int o[] = {1, a}; // KO
28 static int p[] = {[0] = a, [1] = 1}; // KO
29 static int q[] = {[0] = 1, [1] = a}; // KO
30
31 static void r(void) {
32 int a = 0;
33 int b = a; // OK
34 }
35
36 static void s(void) {
37 int a = 1;
38 static int b = a; // KO
39 }
40
41 /*
42 * check-name: static storage object initializer constness verification.
43 * check-command: sparse -Wconstexpr-not-const $file
44 *
45 * check-error-start
46 constexpr-init.c:16:21: warning: non-constant initializer for static object
47 constexpr-init.c:17:25: warning: non-constant initializer for static object
48 constexpr-init.c:18:29: warning: non-constant initializer for static object
49 constexpr-init.c:19:32: warning: non-constant initializer for static object
50 constexpr-init.c:21:26: warning: non-constant initializer for static object
51 constexpr-init.c:22:40: warning: non-constant initializer for static object
52 constexpr-init.c:23:49: warning: non-constant initializer for static object
53 constexpr-init.c:24:52: warning: non-constant initializer for static object
54 constexpr-init.c:26:19: warning: non-constant initializer for static object
55 constexpr-init.c:27:22: warning: non-constant initializer for static object
56 constexpr-init.c:28:25: warning: non-constant initializer for static object
57 constexpr-init.c:29:34: warning: non-constant initializer for static object
58 constexpr-init.c:38:24: warning: non-constant initializer for static object
59 * check-error-end
60 */
|
22 static struct B k= {.c = 1, .d = {.a = a, .b = {1, 1}}}; // KO
23 static struct B l= {.c = 1, .d = {.a = 1, .b = {a, 1}}}; // KO
24 static struct B m= {.c = 1, .d = {.a = 1, .b = {1, a}}}; // KO
25
26 static int n[] = {a, 1}; // KO
27 static int o[] = {1, a}; // KO
28 static int p[] = {[0] = a, [1] = 1}; // KO
29 static int q[] = {[0] = 1, [1] = a}; // KO
30
31 static void r(void) {
32 int a = 0;
33 int b = a; // OK
34 }
35
36 static void s(void) {
37 int a = 1;
38 static int b = a; // KO
39 }
40
41 /*
42 * check-name: constexprness static storage object initializer
43 * check-command: sparse -Wconstexpr-not-const $file
44 *
45 * check-error-start
46 constexpr-init.c:16:21: warning: non-constant initializer for static object
47 constexpr-init.c:17:25: warning: non-constant initializer for static object
48 constexpr-init.c:18:29: warning: non-constant initializer for static object
49 constexpr-init.c:19:32: warning: non-constant initializer for static object
50 constexpr-init.c:21:26: warning: non-constant initializer for static object
51 constexpr-init.c:22:40: warning: non-constant initializer for static object
52 constexpr-init.c:23:49: warning: non-constant initializer for static object
53 constexpr-init.c:24:52: warning: non-constant initializer for static object
54 constexpr-init.c:26:19: warning: non-constant initializer for static object
55 constexpr-init.c:27:22: warning: non-constant initializer for static object
56 constexpr-init.c:28:25: warning: non-constant initializer for static object
57 constexpr-init.c:29:34: warning: non-constant initializer for static object
58 constexpr-init.c:38:24: warning: non-constant initializer for static object
59 * check-error-end
60 */
|