Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-7.c
blobcb2addf3af43942db6c29a5d0b4a1a4fc52ed79f
1 /* Test to verify that --param ssa_name_def_chain_limit can be used to
2 limit the maximum number of SSA_NAME assignments the warning follows.
3 { dg-do compile }
4 { dg-options "-O2 -Wall -Wno-array-bounds --param ssa-name-def-chain-limit=5" } */
6 #define NOIPA __attribute__ ((noipa))
8 void* memset (void*, int, __SIZE_TYPE__);
10 char a9[9];
12 void sink (const char*, ...);
14 NOIPA void g2 (int i)
16 if (i < 1) i = 1;
18 char *p0 = a9;
19 char *p1 = p0 + i;
20 char *p2 = p1 + i;
22 sink (p0, p1, p2);
24 memset (p2, 0, 8); // { dg-warning "\\\[-Wstringop-overflow" }
27 NOIPA void g3 (int i)
29 if (i < 1) i = 1;
31 char *p0 = a9;
32 char *p1 = p0 + i;
33 char *p2 = p1 + i;
34 char *p3 = p2 + i;
36 sink (p0, p1, p2, p3);
38 memset (p3, 0, 7); // { dg-warning "\\\[-Wstringop-overflow" }
41 NOIPA void g4 (int i)
43 if (i < 1) i = 1;
45 char *p0 = a9;
46 char *p1 = p0 + i;
47 char *p2 = p1 + i;
48 char *p3 = p2 + i;
49 char *p4 = p3 + i;
51 sink (p0, p1, p2, p3, p4);
53 memset (p4, 0, 6); // { dg-warning "\\\[-Wstringop-overflow" }
56 NOIPA void g5 (int i)
58 if (i < 1) i = 1;
60 char *p0 = a9;
61 char *p1 = p0 + i;
62 char *p2 = p1 + i;
63 char *p3 = p2 + i;
64 char *p4 = p3 + i;
65 char *p5 = p4 + i;
67 sink (p0, p1, p2, p3, p4, p5);
69 memset (p5, 0, 5); // { dg-warning "\\\[-Wstringop-overflow" }
72 NOIPA void g6 (int i)
74 if (i < 1) i = 1;
76 char *p0 = a9;
77 char *p1 = p0 + i;
78 char *p2 = p1 + i;
79 char *p3 = p2 + i;
80 char *p4 = p3 + i;
81 char *p5 = p4 + i;
82 char *p6 = p5 + i;
84 sink (p0, p1, p2, p3, p4, p5, p6);
86 memset (p6, 0, 4);
89 NOIPA void g7 (int i)
91 if (i < 1) i = 1;
93 char *p0 = a9;
94 char *p1 = p0 + i;
95 char *p2 = p1 + i;
96 char *p3 = p2 + i;
97 char *p4 = p3 + i;
98 char *p5 = p4 + i;
99 char *p6 = p5 + i;
100 char *p7 = p6 + i;
102 sink (p0, p1, p2, p3, p4, p5, p6, p7);
104 memset (p7, 0, 4);
107 NOIPA void g8 (int i)
109 if (i < 1) i = 1;
111 char *p0 = a9;
112 char *p1 = p0 + i;
113 char *p2 = p1 + i;
114 char *p3 = p2 + i;
115 char *p4 = p3 + i;
116 char *p5 = p4 + i;
117 char *p6 = p5 + i;
118 char *p7 = p6 + i;
119 char *p8 = p7 + i;
121 sink (p0, p1, p2, p3, p4, p5, p6, p7, p8);
123 memset (p8, 0, 2);