aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-11-16 17:42:22 +0100
committerJakub Jelinek <jakub@redhat.com>2023-11-16 17:42:22 +0100
commit0fa32aeaa6da4ef9566d98a6fb541dd7427d7d36 (patch)
tree835da0f2c0d8c429ac09888f0cceeb97da1696dc /gcc/cp
parent06ff410e0dea135d41bc5f7a9a007d7ba6822dbf (diff)
downloadgcc-0fa32aeaa6da4ef9566d98a6fb541dd7427d7d36.zip
gcc-0fa32aeaa6da4ef9566d98a6fb541dd7427d7d36.tar.gz
gcc-0fa32aeaa6da4ef9566d98a6fb541dd7427d7d36.tar.bz2
c++: Fix error recovery ICE [PR112365]
check_field_decls for DECL_C_BIT_FIELD FIELD_DECLs with error_mark_node TREE_TYPE continues early and doesn't call check_bitfield_decl which would either set DECL_BIT_FIELD, or clear DECL_C_BIT_FIELD. So, the following testcase ICEs after emitting tons of errors, because SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD asserts DECL_BIT_FIELD. The patch skips that for FIELD_DECLs with error_mark_node, another option would be to check DECL_BIT_FIELD in addition to DECL_C_BIT_FIELD. 2023-11-16 Jakub Jelinek <jakub@redhat.com> PR c++/112365 * class.cc (layout_class_type): Don't SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD on FIELD_DECLs with error_mark_node type. * g++.dg/cpp0x/pr112365.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/class.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 9d4d95f..4766b7c 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -6962,7 +6962,8 @@ layout_class_type (tree t, tree *virtuals_p)
check_bitfield_decl eventually sets DECL_SIZE (field)
to that width. */
&& (DECL_SIZE (field) == NULL_TREE
- || integer_zerop (DECL_SIZE (field))))
+ || integer_zerop (DECL_SIZE (field)))
+ && TREE_TYPE (field) != error_mark_node)
SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD (field, 1);
check_non_pod_aggregate (field);
}