Print this page
new smatch
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/smatch/src/validation/constexpr-init.c
+++ new/usr/src/tools/smatch/src/validation/constexpr-init.c
1 1 static int a = 1; // OK
2 2 static int b[2] = {1, 1}; // OK
3 3 static void c(void) {}
4 4
5 5 struct A {
6 6 int a;
7 7 int b[2];
8 8 };
9 9
10 10 struct B {
11 11 int c;
12 12 struct A d;
13 13 };
14 14
15 15 static struct B d= {1, {1, {1, 1}}}; // OK
16 16 static struct B e= {a, {1, {1, 1}}}; // KO
17 17 static struct B f= {1, {a, {1, 1}}}; // KO
18 18 static struct B g= {1, {1, {a, 1}}}; // KO
19 19 static struct B h= {1, {1, {1, a}}}; // KO
20 20 static struct B i= {.c = 1, .d = {.a = 1, .b = {1, 1}}}; // OK
21 21 static struct B j= {.c = a, .d = {.a = 1, .b = {1, 1}}}; // KO
22 22 static struct B k= {.c = 1, .d = {.a = a, .b = {1, 1}}}; // KO
23 23 static struct B l= {.c = 1, .d = {.a = 1, .b = {a, 1}}}; // KO
24 24 static struct B m= {.c = 1, .d = {.a = 1, .b = {1, a}}}; // KO
25 25
26 26 static int n[] = {a, 1}; // KO
27 27 static int o[] = {1, a}; // KO
28 28 static int p[] = {[0] = a, [1] = 1}; // KO
29 29 static int q[] = {[0] = 1, [1] = a}; // KO
30 30
31 31 static void r(void) {
↓ open down ↓ |
31 lines elided |
↑ open up ↑ |
32 32 int a = 0;
33 33 int b = a; // OK
34 34 }
35 35
36 36 static void s(void) {
37 37 int a = 1;
38 38 static int b = a; // KO
39 39 }
40 40
41 41 /*
42 - * check-name: static storage object initializer constness verification.
42 + * check-name: constexprness static storage object initializer
43 43 * check-command: sparse -Wconstexpr-not-const $file
44 44 *
45 45 * check-error-start
46 46 constexpr-init.c:16:21: warning: non-constant initializer for static object
47 47 constexpr-init.c:17:25: warning: non-constant initializer for static object
48 48 constexpr-init.c:18:29: warning: non-constant initializer for static object
49 49 constexpr-init.c:19:32: warning: non-constant initializer for static object
50 50 constexpr-init.c:21:26: warning: non-constant initializer for static object
51 51 constexpr-init.c:22:40: warning: non-constant initializer for static object
52 52 constexpr-init.c:23:49: warning: non-constant initializer for static object
53 53 constexpr-init.c:24:52: warning: non-constant initializer for static object
54 54 constexpr-init.c:26:19: warning: non-constant initializer for static object
55 55 constexpr-init.c:27:22: warning: non-constant initializer for static object
56 56 constexpr-init.c:28:25: warning: non-constant initializer for static object
57 57 constexpr-init.c:29:34: warning: non-constant initializer for static object
58 58 constexpr-init.c:38:24: warning: non-constant initializer for static object
59 59 * check-error-end
60 60 */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX