From: Martin Sebor Date: Sat, 21 Sep 2019 22:32:59 +0000 (+0000) Subject: PR middle-end/91830 - Bogus -Warray-bounds on strcpy into a member X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=810118592aaa82a6dc460cf6234aa738bf9bbbea;p=gcc.git PR middle-end/91830 - Bogus -Warray-bounds on strcpy into a member PR middle-end/91830 - Bogus -Warray-bounds on strcpy into a member of a subobject compiling binutils gcc/ChangeLog: * gcc/gimple-ssa-warn-restrict.c (builtin_memref::set_base_and_offset): Simplify computation of the offset of the referenced subobject. gcc/testsuite/ChangeLog: * gcc/testsuite/gcc.dg/Warray-bounds-47.c: New test. From-SVN: r276022 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 014dd8d1a7e..72b2151bb9d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-09-21 Martin Sebor + + PR middle-end/91830 + * gcc/gimple-ssa-warn-restrict.c (builtin_memref::set_base_and_offset): + Simplify computation of the offset of the referenced subobject. + 2019-09-21 Iain Sandoe * config/darwin.c (machopic_legitimize_pic_address): Check diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c index 4f6e535ff27..f452debf93b 100644 --- a/gcc/gimple-ssa-warn-restrict.c +++ b/gcc/gimple-ssa-warn-restrict.c @@ -517,14 +517,8 @@ builtin_memref::set_base_and_offset (tree expr) struct S { char a, b[3]; } s[2]; strcpy (s[1].b, "1234"); REFOFF is set to s[1].b - (char*)s. */ - tree basetype = TREE_TYPE (TREE_TYPE (base)); - if (tree basesize = TYPE_SIZE_UNIT (basetype)) - if (TREE_CODE (basesize) == INTEGER_CST) - { - offset_int size = wi::to_offset (basesize); - offset_int off = tree_to_shwi (memrefoff); - refoff += size * (off / size); - } + offset_int off = tree_to_shwi (memrefoff); + refoff += off; } if (!integer_zerop (memrefoff)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e7e62bf8bbe..412616d8f33 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-09-21 Martin Sebor + + PR middle-end/91830 + * gcc/testsuite/gcc.dg/Warray-bounds-47.c: New test. + 2019-09-21 Jakub Jelinek PR c++/30277 diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-47.c b/gcc/testsuite/gcc.dg/Warray-bounds-47.c new file mode 100644 index 00000000000..06ad488d1e0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-47.c @@ -0,0 +1,429 @@ +/* PR middle-end/91830 - Bogus -Warray-bounds on strcpy into a member + of a subobject compiling binutils + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +extern char* strcpy (char*, const char*); +extern void sink (void*); + +#define S36 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + +#define S(N) (S36 + sizeof (S36) - N - 1) + +/* In the test macro, prevent the strcpy to memcpy transformation + by using a local array initialized with the string literal. Without + it, GCC transforms the strcpy call with memcpy which (unfortunately) + permits accesses that cross subobject boundaries. */ +#define T(obj, mem, n) \ + do { \ + struct A *pa = &obj; \ + const char a[] = S36; \ + strcpy (pa->mem, a + sizeof a - n - 1); \ + sink (&obj); \ + } while (0) + + +struct A { char a[3]; char b[5]; }; +struct B { char c[7]; struct A a; struct A a2[2]; }; + +extern struct B b[]; + +void array_nowarn (int i) +{ + struct B *pb = b; + + T (pb[0].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[1].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[123].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[i].a, a, 0); + T (pb[i].a, a, 1); + T (pb[i].a, a, 2); + + + T (pb[0].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[1].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[i].a, b, 0); + T (pb[i].a, b, 1); + T (pb[i].a, b, 2); + T (pb[i].a, b, 3); + T (pb[i].a, b, 4); + + + T (pb[0].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[1].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[i].a2[0], b, 0); + T (pb[i].a2[0], b, 1); + T (pb[i].a2[0], b, 2); + T (pb[i].a2[0], b, 3); + T (pb[i].a2[0], b, 4); + + T (pb[i].a2[1], b, 0); + T (pb[i].a2[1], b, 1); + T (pb[i].a2[1], b, 2); + T (pb[i].a2[1], b, 3); + T (pb[i].a2[1], b, 4); +} + +void array_warn (int i) +{ + struct B *pb = b; + + T (pb[0].a, a, 3); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a, a, 4); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a, a, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a, a, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a, a, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a, a, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a, a, 7); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, a, 8); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + + T (pb[0].a, b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a, b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a, b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a, b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a, b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a, b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a, b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + + T (pb[0].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + T (pb[0].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } +} + +void ptr_nowarn (struct B *pb, int i) +{ + T (pb[-123].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[-123].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[-123].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[-2].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[-2].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[-2].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[-1].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[-1].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[-1].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[0].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[1].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[123].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[i].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[i].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[i].a, a, 2); // { dg-bogus "\\\[-W" } + + + T (pb[-123].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[-123].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[-123].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[-123].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[-123].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-2].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[-2].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[-2].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[-2].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[-2].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-1].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[-1].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[-1].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[-1].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[-1].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[0].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[1].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[i].a, b, 0); + T (pb[i].a, b, 1); + T (pb[i].a, b, 2); + T (pb[i].a, b, 3); + T (pb[i].a, b, 4); + + + T (pb[-123].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-2].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-1].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[0].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[1].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[i].a2[0], b, 0); + T (pb[i].a2[0], b, 1); + T (pb[i].a2[0], b, 2); + T (pb[i].a2[0], b, 3); + T (pb[i].a2[0], b, 4); + + T (pb[-123].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-2].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-1].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[0].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[0].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[0].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[1].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[1].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[1].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[i].a2[1], b, 0); + T (pb[i].a2[1], b, 1); + T (pb[i].a2[1], b, 2); + T (pb[i].a2[1], b, 3); + T (pb[i].a2[1], b, 4); + + T (pb[i].a2[i], b, 0); + T (pb[i].a2[i], b, 1); + T (pb[i].a2[i], b, 2); + T (pb[i].a2[i], b, 3); + T (pb[i].a2[i], b, 4); +} + +void ptr_warn (struct B *pb, int i) +{ + T (pb[-987].a, a, 8); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-654].a, a, 7); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-2].a, a, 6); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-2].a, a, 5); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-1].a, a, 3); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-1].a, a, 4); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[0].a, a, 3); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a, a, 4); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a, a, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a, a, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a, a, 7); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a, a, 8); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a, a, 3); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, a, 4); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, a, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + + T (pb[-987].a, b, 10); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-654].a, b, 9); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-2].a, b, 8); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-2].a, b, 7); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-1].a, b, 6); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-1].a, b, 5); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[0].a, b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a, b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a, b, 7); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a, b, 8); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a, b, 9); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a, b, 10); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a, b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, b, 7); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + + T (pb[-987].a2[0], b, 10); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-654].a2[0], b, 9); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-2].a2[0], b, 8); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-2].a2[0], b, 7); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-1].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-1].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[0].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a2[0], b, 7); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a2[0], b, 8); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a2[0], b, 9); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a2[0], b, 10); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[0], b, 7); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + T (pb[-987].a2[1], b, 10); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-654].a2[1], b, 9); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-2].a2[1], b, 8); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-2].a2[1], b, 7); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-1].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-1].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[0].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a2[1], b, 7); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a2[1], b, 8); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a2[1], b, 9); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a2[1], b, 10); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[1], b, 7); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + T (pb[i].a2[i], b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[i], b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[i], b, 7); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } +}