diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2013-12-02 19:50:55 +0000 |
---|---|---|
committer | Bernd Edlinger <edlinger@gcc.gnu.org> | 2013-12-02 19:50:55 +0000 |
commit | 2399cad0909d5753f774f670a19efd329d020b3b (patch) | |
tree | 569bc9e6949ab42a3b0713707ffc43092cf900ed /gcc/expr.c | |
parent | 72ee07fb7620604030a5713bf8967af64dfbe5c2 (diff) | |
download | gcc-2399cad0909d5753f774f670a19efd329d020b3b.zip gcc-2399cad0909d5753f774f670a19efd329d020b3b.tar.gz gcc-2399cad0909d5753f774f670a19efd329d020b3b.tar.bz2 |
Fix C++0x memory model for unaligned fields in packed...
2013-12-02 Bernd Edlinger <bernd.edlinger@hotmail.de>
Fix C++0x memory model for unaligned fields in packed, aligned(4)
structures with -fno-strict-volatile-bitfields on STRICT_ALIGNMENT
targets like arm-none-eabi.
* expr.c (expand_assignment): Handle normal fields like bit regions.
testsuite:
2013-12-02 Bernd Edlinger <bernd.edlinger@hotmail.de>
* gcc.dg/pr56997-4.c: New testcase.
From-SVN: r205597
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -4824,6 +4824,17 @@ expand_assignment (tree to, tree from, bool nontemporal) if (TREE_CODE (to) == COMPONENT_REF && DECL_BIT_FIELD_TYPE (TREE_OPERAND (to, 1))) get_bit_range (&bitregion_start, &bitregion_end, to, &bitpos, &offset); + /* The C++ memory model naturally applies to byte-aligned fields. + However, if we do not have a DECL_BIT_FIELD_TYPE but BITPOS or + BITSIZE are not byte-aligned, there is no need to limit the range + we can access. This can occur with packed structures in Ada. */ + else if (bitsize > 0 + && bitsize % BITS_PER_UNIT == 0 + && bitpos % BITS_PER_UNIT == 0) + { + bitregion_start = bitpos; + bitregion_end = bitpos + bitsize - 1; + } to_rtx = expand_expr (tem, NULL_RTX, VOIDmode, EXPAND_WRITE); |