diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-04-23 09:59:57 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-04-23 09:59:57 +0200 |
commit | a39ed81b8a0b46320a7c6ece3f7ad4c3f8519609 (patch) | |
tree | aba814967463c0754dc4a2574277ff2ea015ab61 /gcc/config | |
parent | e2a71816b4949225498bec37e947293aa7f5841b (diff) | |
download | gcc-a39ed81b8a0b46320a7c6ece3f7ad4c3f8519609.zip gcc-a39ed81b8a0b46320a7c6ece3f7ad4c3f8519609.tar.gz gcc-a39ed81b8a0b46320a7c6ece3f7ad4c3f8519609.tar.bz2 |
rs6000: Fix C++14 vs. C++17 ABI bug on powerpc64le [PR94707]
As mentioned in the PR and on IRC, the recently added struct-layout-1.exp
new tests FAIL on powerpc64le-linux (among other targets).
FAIL: tmpdir-g++.dg-struct-layout-1/t032 cp_compat_x_tst.o-cp_compat_y_tst.o execute
FAIL: tmpdir-g++.dg-struct-layout-1/t058 cp_compat_x_tst.o-cp_compat_y_tst.o execute
FAIL: tmpdir-g++.dg-struct-layout-1/t059 cp_compat_x_tst.o-cp_compat_y_tst.o execute
in particular. The problem is that the presence or absence of the C++17
artificial empty base fields, which have non-zero TYPE_SIZE, but zero
DECL_SIZE, change the ABI decisions, if it is present (-std=c++17), the type
might not be considered homogeneous, while if it is absent (-std=c++14), it
can be.
The following patch fixes that and emits a -Wpsabi inform; perhaps more
often than it could, because the fact that rs6000_discover_homogeneous_aggregate
returns true when it didn't in in GCC 7/8/9 with -std=c++17 doesn't still
mean it will make a different ABI decision, but the warning triggered only
on the test I've changed (the struct-layout-1.exp tests use -w -Wno-psabi
already).
2020-04-23 Jakub Jelinek <jakub@redhat.com>
PR target/94707
* config/rs6000/rs6000-call.c (rs6000_aggregate_candidate): Add
cxx17_empty_base_seen argument. Pass it to recursive calls.
Ignore cxx17_empty_base_field_p fields after setting
*cxx17_empty_base_seen to true.
(rs6000_discover_homogeneous_aggregate): Adjust
rs6000_aggregate_candidate caller. With -Wpsabi, diagnose homogeneous
aggregates with C++17 empty base fields.
* g++.dg/tree-ssa/pr27830.C: Use -Wpsabi -w for -std=c++17 and higher.
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/rs6000/rs6000-call.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index e08621a..a9ae7ab 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -5528,7 +5528,8 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = { sub-tree. */ static int -rs6000_aggregate_candidate (const_tree type, machine_mode *modep) +rs6000_aggregate_candidate (const_tree type, machine_mode *modep, + bool *cxx17_empty_base_seen) { machine_mode mode; HOST_WIDE_INT size; @@ -5598,7 +5599,8 @@ rs6000_aggregate_candidate (const_tree type, machine_mode *modep) || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) return -1; - count = rs6000_aggregate_candidate (TREE_TYPE (type), modep); + count = rs6000_aggregate_candidate (TREE_TYPE (type), modep, + cxx17_empty_base_seen); if (count == -1 || !index || !TYPE_MAX_VALUE (index) @@ -5636,7 +5638,14 @@ rs6000_aggregate_candidate (const_tree type, machine_mode *modep) if (TREE_CODE (field) != FIELD_DECL) continue; - sub_count = rs6000_aggregate_candidate (TREE_TYPE (field), modep); + if (cxx17_empty_base_field_p (field)) + { + *cxx17_empty_base_seen = true; + continue; + } + + sub_count = rs6000_aggregate_candidate (TREE_TYPE (field), modep, + cxx17_empty_base_seen); if (sub_count < 0) return -1; count += sub_count; @@ -5669,7 +5678,8 @@ rs6000_aggregate_candidate (const_tree type, machine_mode *modep) if (TREE_CODE (field) != FIELD_DECL) continue; - sub_count = rs6000_aggregate_candidate (TREE_TYPE (field), modep); + sub_count = rs6000_aggregate_candidate (TREE_TYPE (field), modep, + cxx17_empty_base_seen); if (sub_count < 0) return -1; count = count > sub_count ? count : sub_count; @@ -5710,7 +5720,9 @@ rs6000_discover_homogeneous_aggregate (machine_mode mode, const_tree type, && AGGREGATE_TYPE_P (type)) { machine_mode field_mode = VOIDmode; - int field_count = rs6000_aggregate_candidate (type, &field_mode); + bool cxx17_empty_base_seen = false; + int field_count = rs6000_aggregate_candidate (type, &field_mode, + &cxx17_empty_base_seen); if (field_count > 0) { @@ -5725,6 +5737,18 @@ rs6000_discover_homogeneous_aggregate (machine_mode mode, const_tree type, *elt_mode = field_mode; if (n_elts) *n_elts = field_count; + if (cxx17_empty_base_seen && warn_psabi) + { + static const_tree last_reported_type; + if (type != last_reported_type) + { + inform (input_location, + "parameter passing for argument of type %qT " + "when C++17 is enabled changed to match C++14 " + "in GCC 10.1", type); + last_reported_type = type; + } + } return true; } } |