aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/tree.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-03-14 16:17:32 +0100
committerJakub Jelinek <jakub@redhat.com>2023-03-14 16:17:32 +0100
commitc35cf160a0ed81570cff6600dba465cf95fa80fa (patch)
tree81d3ab44a48fc02958b1c4af22d7b1943cfcb8a1 /gcc/cp/tree.cc
parent0e6f87835ccabfe84afe412583544ff6e6292352 (diff)
downloadgcc-c35cf160a0ed81570cff6600dba465cf95fa80fa.zip
gcc-c35cf160a0ed81570cff6600dba465cf95fa80fa.tar.gz
gcc-c35cf160a0ed81570cff6600dba465cf95fa80fa.tar.bz2
c++: Treat unnamed bitfields as padding for __has_unique_object_representations [PR109096]
As reported in the PR, for __has_unique_object_representations we were treating unnamed bitfields as named ones, which is wrong, they are actually padding. THe following patch fixes that. 2023-03-14 Jakub Jelinek <jakub@redhat.com> PR c++/109096 * tree.cc (record_has_unique_obj_representations): Ignore unnamed bitfields. * g++.dg/cpp1z/has-unique-obj-representations3.C: New test.
Diffstat (limited to 'gcc/cp/tree.cc')
-rw-r--r--gcc/cp/tree.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index de83d41..16b8fcb 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -4851,7 +4851,7 @@ record_has_unique_obj_representations (const_tree t, const_tree sz)
DECL_SIZE (field)))
return false;
}
- else if (DECL_C_BIT_FIELD (field))
+ else if (DECL_C_BIT_FIELD (field) && !DECL_UNNAMED_BIT_FIELD (field))
{
tree btype = DECL_BIT_FIELD_TYPE (field);
if (!type_has_unique_obj_representations (btype))
@@ -4862,7 +4862,7 @@ record_has_unique_obj_representations (const_tree t, const_tree sz)
offset_int cur = 0;
for (tree field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
- if (TREE_CODE (field) == FIELD_DECL)
+ if (TREE_CODE (field) == FIELD_DECL && !DECL_UNNAMED_BIT_FIELD (field))
{
offset_int fld = wi::to_offset (DECL_FIELD_OFFSET (field));
offset_int bitpos = wi::to_offset (DECL_FIELD_BIT_OFFSET (field));