aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2008-06-13 10:20:57 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2008-06-13 10:20:57 +0000
commit9133c85e1a42213e7e09ba917fae7e57e06a236c (patch)
treeffb72b25b3366639abc607ceaa8c9633577cdf14 /gcc/builtins.c
parent6cf598659e764d8955a1a90c32d2519ab689cea0 (diff)
downloadgcc-9133c85e1a42213e7e09ba917fae7e57e06a236c.zip
gcc-9133c85e1a42213e7e09ba917fae7e57e06a236c.tar.gz
gcc-9133c85e1a42213e7e09ba917fae7e57e06a236c.tar.bz2
re PR middle-end/36520 (ICE in get_memory_rtx)
PR middle-end/36520 * builtins.c (get_memory_rtx): Test for the presence of DECL_SIZE_UNIT before evaluating it. From-SVN: r136747
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index edc5d5f..b3fc304 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -1125,14 +1125,16 @@ get_memory_rtx (tree exp, tree len)
&& (TREE_INT_CST_LOW (DECL_SIZE (field))
% BITS_PER_UNIT) == 0));
+ /* If we can prove that the memory starting at XEXP (mem, 0) and
+ ending at XEXP (mem, 0) + LENGTH will fit into this field, we
+ can keep the COMPONENT_REF in MEM_EXPR. But be careful with
+ fields without DECL_SIZE_UNIT like flexible array members. */
if (length >= 0
+ && DECL_SIZE_UNIT (field)
&& host_integerp (DECL_SIZE_UNIT (field), 0))
{
HOST_WIDE_INT size
= TREE_INT_CST_LOW (DECL_SIZE_UNIT (field));
- /* If we can prove the memory starting at XEXP (mem, 0)
- and ending at XEXP (mem, 0) + LENGTH will fit into
- this field, we can keep that COMPONENT_REF in MEM_EXPR. */
if (offset <= size
&& length <= size
&& offset + length <= size)