Commit 81011859 by Martin Sebor Committed by Martin Sebor

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
parent e4df9be4
2019-09-21 Martin Sebor <msebor@redhat.com>
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 <iain@sandoe.co.uk> 2019-09-21 Iain Sandoe <iain@sandoe.co.uk>
* config/darwin.c (machopic_legitimize_pic_address): Check * config/darwin.c (machopic_legitimize_pic_address): Check
......
...@@ -517,14 +517,8 @@ builtin_memref::set_base_and_offset (tree expr) ...@@ -517,14 +517,8 @@ builtin_memref::set_base_and_offset (tree expr)
struct S { char a, b[3]; } s[2]; struct S { char a, b[3]; } s[2];
strcpy (s[1].b, "1234"); strcpy (s[1].b, "1234");
REFOFF is set to s[1].b - (char*)s. */ REFOFF is set to s[1].b - (char*)s. */
tree basetype = TREE_TYPE (TREE_TYPE (base)); offset_int off = tree_to_shwi (memrefoff);
if (tree basesize = TYPE_SIZE_UNIT (basetype)) refoff += off;
if (TREE_CODE (basesize) == INTEGER_CST)
{
offset_int size = wi::to_offset (basesize);
offset_int off = tree_to_shwi (memrefoff);
refoff += size * (off / size);
}
} }
if (!integer_zerop (memrefoff)) if (!integer_zerop (memrefoff))
......
2019-09-21 Martin Sebor <msebor@redhat.com>
PR middle-end/91830
* gcc/testsuite/gcc.dg/Warray-bounds-47.c: New test.
2019-09-21 Jakub Jelinek <jakub@redhat.com> 2019-09-21 Jakub Jelinek <jakub@redhat.com>
PR c++/30277 PR c++/30277
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment