db/fixup_kernel.sh: update vfs_write() code
[smatch.git] / validation / constexpr-pointer-arith.c
blobf27d117a0ceae626db7e324ca8e8b4d4438d1eb6
1 static int a = 1;
2 static int b[2] = {1, 1};
4 static int *c = &b[1]; // OK
5 static int *d = (int*)0 + 1; // OK
6 static int *e = &b[1] + 1; // OK
7 static int *f = b + 1; // OK
8 static int *g = d + 1; // KO
9 static int *h = &a + 1; // OK
10 static int *i = &b[1] + 1; // OK
11 static int *j = b + 1; // OK
12 static int *k = d + 1; // KO
13 static int *l = &*&b[1]; // OK
14 static int *m = &*(&a + 1); // OK
15 static int *n = &*(&b[1] + 1); // OK
16 static int *o = &*(b + 1); // OK
17 static int *p = &*(d + 1); // KO
20 * check-name: consrexprness pointer arithmetic
21 * check-command: sparse -Wconstexpr-not-const $file
23 * check-error-start
24 constexpr-pointer-arith.c:8:19: warning: non-constant initializer for static object
25 constexpr-pointer-arith.c:12:19: warning: non-constant initializer for static object
26 constexpr-pointer-arith.c:17:22: warning: non-constant initializer for static object
27 * check-error-end