libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-53.c
blobcd8fa3202eb686722b1fb6c718bd9ebdb6ae64e1
1 /* PR middle-end/96384 - bogus -Wstringop-overflow= storing into
2 multidimensional array with index in range
3 { dg-do compile }
4 { dg-options "-O2 -Wall" } */
6 #define SHRT_MAX __SHRT_MAX__
7 #define SHRT_MIN (-SHRT_MAX - 1)
8 #define INT_MAX __INT_MAX__
9 #define INT_MIN (-INT_MAX - 1)
10 #define LONG_MAX __LONG_MAX__
11 #define LONG_MIN (-LONG_MAX - 1)
13 #define USHRT_MAX (SHRT_MAX * 2 + 1)
14 #define UINT_MAX ~0U
15 #define ULONG_MAX ~0LU
17 char ca3_5_7[3][5][7];
19 void nowarn_ca_3_5_ssi (short i)
21 if (i > SHRT_MAX - 1)
22 i = SHRT_MAX - 1;
24 ca3_5_7[i][0][0] = __LINE__;
25 ca3_5_7[i][0][1] = __LINE__;
26 ca3_5_7[i][0][2] = __LINE__;
27 ca3_5_7[i][0][3] = __LINE__;
28 ca3_5_7[i][0][4] = __LINE__;
29 ca3_5_7[i][0][5] = __LINE__;
30 ca3_5_7[i][0][6] = __LINE__;
32 ca3_5_7[i][1][0] = __LINE__;
33 ca3_5_7[i][1][1] = __LINE__;
34 ca3_5_7[i][1][2] = __LINE__;
35 ca3_5_7[i][1][3] = __LINE__;
36 ca3_5_7[i][1][4] = __LINE__;
37 ca3_5_7[i][1][5] = __LINE__;
38 ca3_5_7[i][1][6] = __LINE__;
40 ca3_5_7[i][2][0] = __LINE__;
41 ca3_5_7[i][2][1] = __LINE__;
42 ca3_5_7[i][2][2] = __LINE__;
43 ca3_5_7[i][2][3] = __LINE__;
44 ca3_5_7[i][2][4] = __LINE__;
45 ca3_5_7[i][2][5] = __LINE__;
46 ca3_5_7[i][2][6] = __LINE__;
48 ca3_5_7[i][3][0] = __LINE__;
49 ca3_5_7[i][3][1] = __LINE__;
50 ca3_5_7[i][3][2] = __LINE__;
51 ca3_5_7[i][3][3] = __LINE__;
52 ca3_5_7[i][3][4] = __LINE__;
53 ca3_5_7[i][3][5] = __LINE__;
54 ca3_5_7[i][3][6] = __LINE__;
56 ca3_5_7[i][4][0] = __LINE__;
57 ca3_5_7[i][4][1] = __LINE__;
58 ca3_5_7[i][4][2] = __LINE__;
59 ca3_5_7[i][4][3] = __LINE__;
60 ca3_5_7[i][4][4] = __LINE__;
61 ca3_5_7[i][4][5] = __LINE__;
62 ca3_5_7[i][4][6] = __LINE__;
64 ca3_5_7[1][i][5] = __LINE__;
65 ca3_5_7[2][3][i] = __LINE__;
68 void nowarn_ca_3_5_usi (unsigned short i)
70 if (i > USHRT_MAX - 1)
71 i = USHRT_MAX - 1;
73 ca3_5_7[i][3][5] = __LINE__;
74 ca3_5_7[1][i][5] = __LINE__;
75 ca3_5_7[2][3][i] = __LINE__;
78 void nowarn_ca_3_5_si (int i)
80 if (i > INT_MAX - 1)
81 i = INT_MAX - 1;
83 ca3_5_7[i][3][5] = __LINE__;
84 ca3_5_7[1][i][5] = __LINE__;
85 ca3_5_7[2][3][i] = __LINE__;
88 void nowarn_ca_3_5_ui (unsigned i)
90 if (i > UINT_MAX - 1)
91 i = UINT_MAX - 1;
93 ca3_5_7[i][3][5] = __LINE__;
94 ca3_5_7[1][i][5] = __LINE__;
95 ca3_5_7[2][3][i] = __LINE__;
98 void nowarn_ca_3_5_li (long i)
100 if (i > LONG_MAX - 1)
101 i = LONG_MAX - 1;
103 ca3_5_7[i][3][5] = __LINE__;
104 ca3_5_7[1][i][5] = __LINE__;
105 ca3_5_7[2][3][i] = __LINE__;
108 void nowarn_ca_3_5_uli (unsigned long i)
110 if (i > ULONG_MAX - 1)
111 i = ULONG_MAX - 1;
113 ca3_5_7[i][3][5] = __LINE__;
114 ca3_5_7[1][i][5] = __LINE__;
115 ca3_5_7[2][3][i] = __LINE__;