Debian Codegraph @

gcc/testsuite/gcc.dg/analyzer/torture/symbolic-10.c

raw
1 /* Verify that -fanalyzer considers that mmfs escapes when passing either:
2 *(mmfs + i)
3 and
4 (&mmfs[i])
5 to an external function (for symbolic i). */
6
7 typedef struct s_mmfile {
8 char *ptr;
9 long size;
10 } mmfile_t;
11
12 void init_mmfile(mmfile_t *ptr);
13
14 long test__init_via_ptr_arith__read_via_array_idx(int i)
15 {
16 mmfile_t mmfs[3];
17 init_mmfile(mmfs + i);
18 return mmfs[i].size; /* { dg-bogus "uninit" } */
19 }
20
21 long test__init_via_array_idx__read_via_ptr_arith(int i)
22 {
23 mmfile_t mmfs[3];
24 init_mmfile(&mmfs[i]);
25 return (mmfs + i)->size; /* { dg-bogus "uninit" } */
26 }
27
28 long test__ptr_arith_for_both(int i)
29 {
30 mmfile_t mmfs[3];
31 init_mmfile(mmfs + i);
32 return (mmfs + i)->size; /* { dg-bogus "uninit" } */
33 }
34
35 long test__array_idx_for_both(int i)
36 {
37 mmfile_t mmfs[3];
38 init_mmfile(&mmfs[i]);
39 return mmfs[i].size; /* { dg-bogus "uninit" } */
40 }