public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5534] c++: Fix error recovery ICE [PR112365]
@ 2023-11-16 16:43 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-11-16 16:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0fa32aeaa6da4ef9566d98a6fb541dd7427d7d36

commit r14-5534-g0fa32aeaa6da4ef9566d98a6fb541dd7427d7d36
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Nov 16 17:42:22 2023 +0100

    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.

Diff:
---
 gcc/cp/class.cc                       | 3 ++-
 gcc/testsuite/g++.dg/cpp0x/pr112365.C | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 9d4d95f85bf..4766b7cf832 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);
     }
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr112365.C b/gcc/testsuite/g++.dg/cpp0x/pr112365.C
new file mode 100644
index 00000000000..23409cba49e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr112365.C
@@ -0,0 +1,8 @@
+// PR c++/112365
+// { dg-do compile { target c++11 } }
+// { dg-excess-errors "" }
+
+template <typename> struct A;
+template <typename T> A <T> foo (T;
+template <typename T> struct A { constexpr A : T {} }
+struct { bar ( { foo (this)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-16 16:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-16 16:43 [gcc r14-5534] c++: Fix error recovery ICE [PR112365] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).