extra: fix bug handling untracked pointers
[smatch.git] / validation / sm_buf_size8.c
blobf6b85e17b9d28b4889e0f1adf7a98f66518efca9
1 #include <stdlib.h>
2 #include "check_debug.h"
4 struct foo {
5 int x, y, z;
6 int count;
7 char msg[0];
8 };
10 struct bar {
11 int x, y, z;
12 int count;
13 char msg[1];
16 struct outer1 {
17 int x, y, z;
18 struct foo foo;
21 struct outer2 {
22 int x, y, z;
23 struct bar bar;
26 int test(void)
28 struct foo *p;
29 struct bar *q;
30 struct outer1 *a;
31 struct outer2 *b;
33 p = malloc(sizeof(*p) + 100);
34 __smatch_buf_size(p->msg);
36 q = malloc(sizeof(*q) + 100);
37 __smatch_buf_size(q->msg);
39 a = malloc(sizeof(*a) + 100);
40 __smatch_buf_size(a->foo);
42 b = malloc(sizeof(*b) + 100);
43 __smatch_buf_size(b->bar);
47 * check-name: smatch buf size #8
48 * check-command: smatch -I.. sm_buf_size8.c
50 * check-output-start
51 sm_buf_size8.c:34 test() buf size: 'p->msg' 100 elements, 100 bytes
52 sm_buf_size8.c:37 test() buf size: 'q->msg' 101 elements, 101 bytes
53 sm_buf_size8.c:40 test() buf size: 'a->foo' 0 elements, 116 bytes
54 sm_buf_size8.c:43 test() buf size: 'b->bar' 0 elements, 120 bytes
55 * check-output-end