annotate gcc/testsuite/c-c++-common/Warray-bounds-8.c @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
1 /* PR c/92326 - wrong bound in zero-length array diagnostics
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
2 { dg-do compile }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
3 { dg-options "-O2 -Wall" } */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
4
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
5 extern int a0[0];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
6 extern int ax[];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
7
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
8 void warn_global_array (void)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
9 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
10 a0[0] = 0; // { dg-warning "array bounds of 'int *\\\[0]'" }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
11 ax[-1] = 0; // { dg-warning "array bounds of 'int *\\\[]'" }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
12 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
13
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
14
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
15 struct S0 { int n, a0[0]; } s0;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
16 struct Sx { int n, ax[]; } sx = { 0 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
17
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
18 void warn_member_array (void)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
19 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
20 s0.a0[0] = 0; // { dg-warning "array bounds of 'int *\\\[0]'" }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
21 sx.ax[0] = 0; // { dg-warning "array bounds of 'int *\\\[]'" }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
22 }