diff options
author | Jiong Wang <jiong.wang@arm.com> | 2015-01-16 10:14:51 +0000 |
---|---|---|
committer | Jiong Wang <jiwang@gcc.gnu.org> | 2015-01-16 10:14:51 +0000 |
commit | 4ae9783ec34fda4e7da9e59d8c7359c150fa3e39 (patch) | |
tree | 7f4d05384f9791b939aff37fa125d72e83cb9294 | |
parent | de37b21e3d945ed6a0bf032078c233854ff38c8e (diff) | |
download | gcc-4ae9783ec34fda4e7da9e59d8c7359c150fa3e39.zip gcc-4ae9783ec34fda4e7da9e59d8c7359c150fa3e39.tar.gz gcc-4ae9783ec34fda4e7da9e59d8c7359c150fa3e39.tar.bz2 |
[Patch] Warn and truncate bitsize when partial overflow happen
PR rtl-optimization/64011
gcc/
* expmed.c (store_bit_field_using_insv): Warn and truncate bitsize when
there is partial overflow.
From-SVN: r219717
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/expmed.c | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 09a0c98..65a80c5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-01-15 Jiong Wang <jiong.wang@arm.com> + + PR rtl-optimization/64011 + * expmed.c (store_bit_field_using_insv): Warn and truncate bitsize when + there is partial overflow. + 2015-01-16 Chung-Ju Wu <jasonwucj@gmail.com> * config/nds32/nds32-protos.h (nds32_expand_epilogue): Change diff --git a/gcc/expmed.c b/gcc/expmed.c index 480601c..beedfc0 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -557,6 +557,21 @@ store_bit_field_using_insv (const extraction_insn *insv, rtx op0, copy_back = true; } + /* There are similar overflow check at the start of store_bit_field_1, + but that only check the situation where the field lies completely + outside the register, while there do have situation where the field + lies partialy in the register, we need to adjust bitsize for this + partial overflow situation. Without this fix, pr48335-2.c on big-endian + will broken on those arch support bit insert instruction, like arm, aarch64 + etc. */ + if (bitsize + bitnum > unit && bitnum < unit) + { + warning (OPT_Wextra, "write of "HOST_WIDE_INT_PRINT_UNSIGNED"bit data " + "outside the bound of destination object, data truncated into " + HOST_WIDE_INT_PRINT_UNSIGNED"bit", bitsize, unit - bitnum); + bitsize = unit - bitnum; + } + /* If BITS_BIG_ENDIAN is zero on a BYTES_BIG_ENDIAN machine, we count "backwards" from the size of the unit we are inserting into. Otherwise, we count bits from the most significant on a |