diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-20 21:17:30 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-20 21:17:30 +0000 |
commit | 4938e520e063b0f1274dc118b2ee07fd9a7e605d (patch) | |
tree | 6cf3a5a5babb67d1351ee60f1f15129bdb7a263b /gcc/tree-ssa-ccp.c | |
parent | 4bcf12c540ceca3aea14ab92c6d1b203e7a35e6f (diff) | |
download | gcc-4938e520e063b0f1274dc118b2ee07fd9a7e605d.tar.gz |
PR tree-optimization/45919
* tree-ssa-ccp.c (fold_nonarray_ctor_reference): Handle flexible
array members.
* gcc.c-torture/compile/pr45919.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165740 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 650494144cd..2d9c1233ea9 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1523,23 +1523,30 @@ fold_nonarray_ctor_reference (tree type, tree ctor, double_int bits_per_unit_cst = uhwi_to_double_int (BITS_PER_UNIT); double_int bitoffset_end; - /* Variable sized objects in static constructors makes no sense. */ + /* Variable sized objects in static constructors makes no sense, + but field_size can be NULL for flexible array members. */ gcc_assert (TREE_CODE (field_offset) == INTEGER_CST && TREE_CODE (byte_offset) == INTEGER_CST - && TREE_CODE (field_size) == INTEGER_CST); + && (field_size != NULL_TREE + ? TREE_CODE (field_size) == INTEGER_CST + : TREE_CODE (TREE_TYPE (cfield)) == ARRAY_TYPE)); /* Compute bit offset of the field. */ bitoffset = double_int_add (tree_to_double_int (field_offset), double_int_mul (byte_offset_cst, bits_per_unit_cst)); /* Compute bit offset where the field ends. */ - bitoffset_end = double_int_add (bitoffset, - tree_to_double_int (field_size)); + if (field_size != NULL_TREE) + bitoffset_end = double_int_add (bitoffset, + tree_to_double_int (field_size)); + else + bitoffset_end = double_int_zero; /* Is OFFSET in the range (BITOFFSET, BITOFFSET_END)? */ if (double_int_cmp (uhwi_to_double_int (offset), bitoffset, 0) >= 0 - && double_int_cmp (uhwi_to_double_int (offset), - bitoffset_end, 0) < 0) + && (field_size == NULL_TREE + || double_int_cmp (uhwi_to_double_int (offset), + bitoffset_end, 0) < 0)) { double_int access_end = double_int_add (uhwi_to_double_int (offset), uhwi_to_double_int (size)); |