diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-02-22 09:29:56 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-02-22 09:29:56 +0100 |
commit | d3d4a52a70f2021b3d84cb35f66ba88190e6b5d3 (patch) | |
tree | ef85c92dac9a135c13fd324d5a1fee8d324e20f0 /gcc/stor-layout.c | |
parent | c5679c37aad3775ecbb41b1a191514b13bf73f77 (diff) | |
download | gcc-d3d4a52a70f2021b3d84cb35f66ba88190e6b5d3.zip gcc-d3d4a52a70f2021b3d84cb35f66ba88190e6b5d3.tar.gz gcc-d3d4a52a70f2021b3d84cb35f66ba88190e6b5d3.tar.bz2 |
re PR c++/84502 (Argument corruption when passing empty templated struct)
PR target/84502
* stor-layout.c (finalize_type_size): Propagate TYPE_EMPTY_P flag
to all type variants.
* g++.dg/torture/pr84502.C: New test.
From-SVN: r257892
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 5fdf81a..a4eeff1 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -1883,6 +1883,9 @@ finalize_type_size (tree type) && TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST) TYPE_SIZE_UNIT (type) = variable_size (TYPE_SIZE_UNIT (type)); + /* Handle empty records as per the x86-64 psABI. */ + TYPE_EMPTY_P (type) = targetm.calls.empty_record_p (type); + /* Also layout any other variants of the type. */ if (TYPE_NEXT_VARIANT (type) || type != TYPE_MAIN_VARIANT (type)) @@ -1895,6 +1898,7 @@ finalize_type_size (tree type) unsigned int precision = TYPE_PRECISION (type); unsigned int user_align = TYPE_USER_ALIGN (type); machine_mode mode = TYPE_MODE (type); + bool empty_p = TYPE_EMPTY_P (type); /* Copy it into all variants. */ for (variant = TYPE_MAIN_VARIANT (type); @@ -1911,11 +1915,9 @@ finalize_type_size (tree type) SET_TYPE_ALIGN (variant, valign); TYPE_PRECISION (variant) = precision; SET_TYPE_MODE (variant, mode); + TYPE_EMPTY_P (variant) = empty_p; } } - - /* Handle empty records as per the x86-64 psABI. */ - TYPE_EMPTY_P (type) = targetm.calls.empty_record_p (type); } /* Return a new underlying object for a bitfield started with FIELD. */ |