aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2016-05-21 11:46:22 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2016-05-21 09:46:22 +0000
commit03b2a15fa54e5ea1d02e86bb036f4692b155151e (patch)
tree7b83f7a1a6cef15449724d6edf6ce71a7de5d2f4 /gcc/tree.c
parent88aea79f3cd5933088c99f0ebe3e34285c2b201d (diff)
downloadgcc-03b2a15fa54e5ea1d02e86bb036f4692b155151e.zip
gcc-03b2a15fa54e5ea1d02e86bb036f4692b155151e.tar.gz
gcc-03b2a15fa54e5ea1d02e86bb036f4692b155151e.tar.bz2
* tree.c (array_at_struct_end_p): Look through MEM_REF.
From-SVN: r236557
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 5a1d167..83dc7d8 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -13076,9 +13076,28 @@ array_at_struct_end_p (tree ref)
ref = TREE_OPERAND (ref, 0);
}
+ tree size = NULL;
+
+ if (TREE_CODE (ref) == MEM_REF
+ && TREE_CODE (TREE_OPERAND (ref, 0)) == ADDR_EXPR)
+ {
+ size = TYPE_SIZE (TREE_TYPE (ref));
+ ref = TREE_OPERAND (TREE_OPERAND (ref, 0), 0);
+ }
+
/* If the reference is based on a declared entity, the size of the array
is constrained by its given domain. (Do not trust commons PR/69368). */
if (DECL_P (ref)
+ /* Be sure the size of MEM_REF target match. For example:
+
+ char buf[10];
+ struct foo *str = (struct foo *)&buf;
+
+ str->trailin_array[2] = 1;
+
+ is valid because BUF allocate enough space. */
+
+ && (!size || operand_equal_p (DECL_SIZE (ref), size, 0))
&& !(flag_unconstrained_commons
&& TREE_CODE (ref) == VAR_DECL && DECL_COMMON (ref)))
return false;