diff options
author | Martin Sebor <msebor@redhat.com> | 2022-01-14 11:13:08 -0700 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2022-01-14 11:13:08 -0700 |
commit | 72332337e3d8acbb21398b8d123f1bfe77a8327e (patch) | |
tree | 94b31c445e4d8804a4bd5e3abc3b2d63fec14e82 /gcc/testsuite/gcc.dg/Wstringop-overflow-15.c | |
parent | 1e6294bb15d2169147c7838f89a9168980b94b47 (diff) | |
download | gcc-72332337e3d8acbb21398b8d123f1bfe77a8327e.zip gcc-72332337e3d8acbb21398b8d123f1bfe77a8327e.tar.gz gcc-72332337e3d8acbb21398b8d123f1bfe77a8327e.tar.bz2 |
Use enclosing object size if it's smaller than member [PR 101475].
Resolves:
PR middle-end/101475 - missing -Wstringop-overflow storing a compound literal
gcc/ChangeLog:
PR middle-end/101475
* pointer-query.cc (handle_component_ref): Use the size of
the enclosing object if it's smaller than the member.
gcc/testsuite/ChangeLog:
PR middle-end/101475
* gcc.dg/Wstringop-overflow-15.c: Remove xfails.
* gcc.dg/Wstringop-overflow-68.c: Adjust, remove xfails.
* gcc.dg/Wstringop-overflow-88.c: New test.
Diffstat (limited to 'gcc/testsuite/gcc.dg/Wstringop-overflow-15.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstringop-overflow-15.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-15.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-15.c index 87f8462..f7dcb94 100644 --- a/gcc/testsuite/gcc.dg/Wstringop-overflow-15.c +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-15.c @@ -29,8 +29,13 @@ void vla_bounded (int n) a[0] = 0; a[1] = 1; + a[31] = 31; + + sink (&a); + a[n] = n; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" { xfail *-*-* } } - a[69] = n; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" } + a[32] = 32; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" } + a[69] = 69; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" } sink (&a); } @@ -56,8 +61,13 @@ void member_vla_bounded (int n) s.a[0] = 0; s.a[1] = 1; + s.a[31] = 31; + + sink (&s); + s.a[n] = n; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" { xfail *-*-* } } - s.a[69] = n; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" { xfail *-*-* } } + s.a[32] = 32; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" } + s.a[69] = 69; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" } sink (&s); } |