Commit 12b38cca by Eric Botcazou Committed by Eric Botcazou

gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): For an ADDR_EXPR,…

gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): For an ADDR_EXPR, do not count the offset of a COMPONENT_REF twice.

	* gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): For an
	ADDR_EXPR, do not count the offset of a COMPONENT_REF twice.

From-SVN: r256766
parent 035181c3
2018-01-16 Eric Botcazou <ebotcazou@adacore.com>
* gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): For an
ADDR_EXPR, do not count the offset of a COMPONENT_REF twice.
2018-01-16 Kelvin Nilsen <kelvin@gcc.gnu.org> 2018-01-16 Kelvin Nilsen <kelvin@gcc.gnu.org>
* config/rs6000/rs6000-p8swap.c (rs6000_gen_stvx): Generate * config/rs6000/rs6000-p8swap.c (rs6000_gen_stvx): Generate
......
...@@ -312,11 +312,11 @@ builtin_memref::builtin_memref (tree expr, tree size) ...@@ -312,11 +312,11 @@ builtin_memref::builtin_memref (tree expr, tree size)
if (TREE_CODE (expr) == ADDR_EXPR) if (TREE_CODE (expr) == ADDR_EXPR)
{ {
poly_int64 off; poly_int64 off;
tree oper = TREE_OPERAND (expr, 0); tree op = TREE_OPERAND (expr, 0);
/* Determine the base object or pointer of the reference /* Determine the base object or pointer of the reference
and its constant offset from the beginning of the base. */ and its constant offset from the beginning of the base. */
base = get_addr_base_and_unit_offset (oper, &off); base = get_addr_base_and_unit_offset (op, &off);
HOST_WIDE_INT const_off; HOST_WIDE_INT const_off;
if (base && off.is_constant (&const_off)) if (base && off.is_constant (&const_off))
...@@ -325,17 +325,11 @@ builtin_memref::builtin_memref (tree expr, tree size) ...@@ -325,17 +325,11 @@ builtin_memref::builtin_memref (tree expr, tree size)
offrange[1] += const_off; offrange[1] += const_off;
/* Stash the reference for offset validation. */ /* Stash the reference for offset validation. */
ref = oper; ref = op;
/* Also stash the constant offset for offset validation. */ /* Also stash the constant offset for offset validation. */
tree_code code = TREE_CODE (oper); if (TREE_CODE (op) == COMPONENT_REF)
if (code == COMPONENT_REF) refoff = const_off;
{
tree field = TREE_OPERAND (ref, 1);
tree fldoff = DECL_FIELD_OFFSET (field);
if (TREE_CODE (fldoff) == INTEGER_CST)
refoff = const_off + wi::to_offset (fldoff);
}
} }
else else
{ {
......
2018-01-16 Eric Botcazou <ebotcazou@adacore.com> 2018-01-16 Eric Botcazou <ebotcazou@adacore.com>
* c-c++-common/Warray-bounds-3.c (test_memmove_bounds): Fix mismatch.
2018-01-16 Eric Botcazou <ebotcazou@adacore.com>
* c-c++-common/Wrestrict.c (test_strcpy_range): Bump string size of one * c-c++-common/Wrestrict.c (test_strcpy_range): Bump string size of one
test and add dg-warning for the -Wstringop-overflow warning. test and add dg-warning for the -Wstringop-overflow warning.
......
...@@ -199,7 +199,8 @@ void test_memmove_bounds (char *d, const char *s, size_t n) ...@@ -199,7 +199,8 @@ void test_memmove_bounds (char *d, const char *s, size_t n)
T (int, 2, a + SR ( 1, 3), pi, n); T (int, 2, a + SR ( 1, 3), pi, n);
T (int, 2, a + SR ( 2, 3), pi, n); T (int, 2, a + SR ( 2, 3), pi, n);
T (int32_t, 2, a + SR ( 3, 4), pi, n); /* { dg-warning "offset \\\[12, 16] is out of the bounds \\\[0, 8] of object .\[^\n\r]+. with type .int32_t ?\\\[2]." } */ const int32_t *pi32 = (const int32_t*)s;
T (int32_t, 2, a + SR ( 3, 4), pi32, n); /* { dg-warning "offset \\\[12, 16] is out of the bounds \\\[0, 8] of object .\[^\n\r]+. with type .int32_t ?\\\[2]." } */
} }
......
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