]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/Wstringop-overflow-21-novec.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-21-novec.c
1 /* PR middle-end/92312 - bogus -Wstringop-overflow storing into a trailing
2 array backed by larger buffer
3 { dg-do compile }
4 { dg-options "-O2 -fno-tree-vectorize -Wall -Wno-array-bounds" } */
5
6 struct S0 { char a, b[0]; };
7
8 void sink (void*);
9
10 void test_store_zero_length (int i)
11 {
12 char a[3];
13 struct S0 *p = (struct S0*)a;
14 p->a = 0;
15 p->b[0] = 0;
16 p->b[1] = 1; // { dg-bogus "\\\[-Wstringop-overflow" }
17 p->b[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" }
18 p->b[i] = 2;
19 sink (p);
20 }
21
22 struct Sx { char a, b[]; };
23
24 void test_store_flexarray (int i)
25 {
26 char a[3];
27 struct Sx *p = (struct Sx*)a;
28 p->a = 0;
29 p->b[0] = 0;
30 p->b[1] = 1; // { dg-bogus "\\\[-Wstringop-overflow" }
31 p->b[2] = 1; // { dg-warning "\\\[-Wstringop-overflow" }
32 p->b[i] = 2;
33 sink (p);
34 }