diff options
author | Xi Ruoyao <xry111@mengyan1223.wang> | 2022-04-02 18:39:51 +0800 |
---|---|---|
committer | Xi Ruoyao <xry111@mengyan1223.wang> | 2022-04-02 19:16:03 +0800 |
commit | be07535d0f43390b8906826cc119473dea514b54 (patch) | |
tree | d3f9908464445232c5b4755bca4f25886be91b75 | |
parent | 2a82301d409d3aa0e0b3b884e4c6daeaa0486d6b (diff) | |
download | gcc-be07535d0f43390b8906826cc119473dea514b54.zip gcc-be07535d0f43390b8906826cc119473dea514b54.tar.gz gcc-be07535d0f43390b8906826cc119473dea514b54.tar.bz2 |
mips: Fix an ICE caused by r12-7962
DECL_SIZE(x) is NULL if x is a flexible array member, but I forgot to
check it in r12-7962. Then if we increase the size of a struct with
flexible array member (by using aligned attribute), the code will
dereference NULL trying to use the "size" of the flexible array member.
gcc/
* config/mips/mips.cc (mips_function_arg): Check if DECL_SIZE is
NULL before dereferencing it.
gcc/testsuite/
* gcc.target/mips/pr102024-4.c: New test.
-rw-r--r-- | gcc/config/mips/mips.cc | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/pr102024-4.c | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc index 7681983..0f24922 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -6054,7 +6054,8 @@ mips_function_arg (cumulative_args_t cum_v, const function_arg_info &arg) an ABI change. */ if (DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD (field)) continue; - if (integer_zerop (DECL_SIZE (field))) + if (DECL_SIZE (field) + && integer_zerop (DECL_SIZE (field))) { zero_width_field_abi_change = true; continue; diff --git a/gcc/testsuite/gcc.target/mips/pr102024-4.c b/gcc/testsuite/gcc.target/mips/pr102024-4.c new file mode 100644 index 0000000..2147cc7 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/pr102024-4.c @@ -0,0 +1,10 @@ +// { dg-do compile } +// { dg-options "-mabi=64 -mhard-float" } + +struct __attribute__((aligned(16))) test { + int x[0]; + double b; + int f[]; +}; + +void check(struct test) {} // { dg-message "the ABI for passing a value containing zero-width fields before an adjacent 64-bit floating-point field was changed in GCC 12.1" } |