public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-9680] c++: fix tree_contains_struct for C++ types [PR101095]
Date: Tue, 22 Mar 2022 05:18:15 +0000 (GMT)	[thread overview]
Message-ID: <20220322051815.6CEBA3945C15@sourceware.org> (raw)

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

commit r11-9680-g0a63e3ee2d5c9aa0e51aa1eb54c3d14c06418ac3
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jul 14 17:10:49 2021 -0400

    c++: fix tree_contains_struct for C++ types [PR101095]
    
    Many of the types from cp-tree.def were only marked as having tree_common,
    when actually most of them have type_non_common.  This broke
    g++.dg/modules/xtreme-header-2, as the modules code relies on
    tree_contains_struct to know what bits it needs to stream.
    
    We don't seem to use type_non_common for TYPE_ARGUMENT_PACK, so I bumped it
    down to TS_TYPE_COMMON.  I tried doing the same in cp_tree_size, but that
    breaks without more extensive changes to tree_node_structure.
    
    Why do we need the init_ts function anyway?  It seems redundant with
    tree_node_structure.
    
            PR c++/101095
    
    gcc/cp/ChangeLog:
    
            * cp-objcp-common.c (cp_common_init_ts): Mark types as types.
            (cp_tree_size): Remove redundant entries.

Diff:
---
 gcc/cp/cp-objcp-common.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index 9847270694a..382528341e1 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -72,10 +72,13 @@ cp_tree_size (enum tree_code code)
     case DEFERRED_NOEXCEPT:	return sizeof (tree_deferred_noexcept);
     case OVERLOAD:		return sizeof (tree_overload);
     case STATIC_ASSERT:         return sizeof (tree_static_assert);
-    case TYPE_ARGUMENT_PACK:
-    case TYPE_PACK_EXPANSION:	return sizeof (tree_type_non_common);
-    case NONTYPE_ARGUMENT_PACK:
-    case EXPR_PACK_EXPANSION:	return sizeof (tree_exp);
+#if 0
+      /* This would match cp_common_init_ts, but breaks GC because
+	 tree_node_structure_for_code returns TS_TYPE_NON_COMMON for all
+	 types.  */
+    case UNBOUND_CLASS_TEMPLATE:
+    case TYPE_ARGUMENT_PACK:	return sizeof (tree_type_common);
+#endif
     case ARGUMENT_PACK_SELECT:	return sizeof (tree_argument_pack_select);
     case TRAIT_EXPR:		return sizeof (tree_trait_expr);
     case LAMBDA_EXPR:           return sizeof (tree_lambda_expr);
@@ -455,13 +458,8 @@ cp_common_init_ts (void)
 
   /* Random new trees.  */
   MARK_TS_COMMON (BASELINK);
-  MARK_TS_COMMON (DECLTYPE_TYPE);
   MARK_TS_COMMON (OVERLOAD);
   MARK_TS_COMMON (TEMPLATE_PARM_INDEX);
-  MARK_TS_COMMON (TYPENAME_TYPE);
-  MARK_TS_COMMON (TYPEOF_TYPE);
-  MARK_TS_COMMON (UNBOUND_CLASS_TEMPLATE);
-  MARK_TS_COMMON (UNDERLYING_TYPE);
 
   /* New decls.  */
   MARK_TS_DECL_COMMON (TEMPLATE_DECL);
@@ -471,10 +469,16 @@ cp_common_init_ts (void)
   MARK_TS_DECL_NON_COMMON (USING_DECL);
 
   /* New Types.  */
+  MARK_TS_TYPE_COMMON (UNBOUND_CLASS_TEMPLATE);
+  MARK_TS_TYPE_COMMON (TYPE_ARGUMENT_PACK);
+
+  MARK_TS_TYPE_NON_COMMON (DECLTYPE_TYPE);
+  MARK_TS_TYPE_NON_COMMON (TYPENAME_TYPE);
+  MARK_TS_TYPE_NON_COMMON (TYPEOF_TYPE);
+  MARK_TS_TYPE_NON_COMMON (UNDERLYING_TYPE);
   MARK_TS_TYPE_NON_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM);
   MARK_TS_TYPE_NON_COMMON (TEMPLATE_TEMPLATE_PARM);
   MARK_TS_TYPE_NON_COMMON (TEMPLATE_TYPE_PARM);
-  MARK_TS_TYPE_NON_COMMON (TYPE_ARGUMENT_PACK);
   MARK_TS_TYPE_NON_COMMON (TYPE_PACK_EXPANSION);
 
   /* Statements.  */


                 reply	other threads:[~2022-03-22  5:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220322051815.6CEBA3945C15@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).