From fc79fc4966060222486458e6b310203e4e8527a1 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 31 Jul 2019 14:49:28 -0400 Subject: [PATCH] Fix copy_node of TEMPLATE_INFO. build_clone uses copy_node to duplicate the TEMPLATE_INFO for a clone, but this clears TREE_CHAIN, which was TI_ARGS in a TEMPLATE_INFO. * cp-tree.h (struct tree_template_info): Use tree_base instead of tree_common. Add tmpl and args fields. (TI_TEMPLATE, TI_ARGS): Adjust. From-SVN: r273943 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/cp-objcp-common.c | 1 - gcc/cp/cp-tree.h | 10 +++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 425eea11a7c..06024eb506d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2019-07-31 Jason Merrill + + Fix copy_node of TEMPLATE_INFO. + * cp-tree.h (struct tree_template_info): Use tree_base instead of + tree_common. Add tmpl and args fields. + (TI_TEMPLATE, TI_ARGS): Adjust. + 2019-07-30 Martin Liska PR tree-optimization/91270 diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index 21d162e5d0c..4c95180bd4b 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -373,7 +373,6 @@ cp_common_init_ts (void) MARK_TS_COMMON (TEMPLATE_TYPE_PARM); MARK_TS_COMMON (TEMPLATE_PARM_INDEX); MARK_TS_COMMON (OVERLOAD); - MARK_TS_COMMON (TEMPLATE_INFO); MARK_TS_COMMON (TYPENAME_TYPE); MARK_TS_COMMON (TYPEOF_TYPE); MARK_TS_COMMON (UNDERLYING_TYPE); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 688924cdd12..c8fa29938e4 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1437,7 +1437,9 @@ typedef struct qualified_typedef_usage_s qualified_typedef_usage_t; (TREE_LANG_FLAG_1 (TEMPLATE_INFO_CHECK (NODE))) struct GTY(()) tree_template_info { - struct tree_common common; + struct tree_base base; + tree tmpl; + tree args; vec *typedefs_needing_access_checking; }; @@ -3420,8 +3422,10 @@ struct GTY(()) lang_decl { ? (TYPE_LANG_SLOT_1 (NODE) = (VAL)) \ : (DECL_TEMPLATE_INFO (TYPE_NAME (NODE)) = (VAL))) -#define TI_TEMPLATE(NODE) TREE_TYPE (TEMPLATE_INFO_CHECK (NODE)) -#define TI_ARGS(NODE) TREE_CHAIN (TEMPLATE_INFO_CHECK (NODE)) +#define TI_TEMPLATE(NODE) \ + ((struct tree_template_info*)TEMPLATE_INFO_CHECK (NODE))->tmpl +#define TI_ARGS(NODE) \ + ((struct tree_template_info*)TEMPLATE_INFO_CHECK (NODE))->args #define TI_PENDING_TEMPLATE_FLAG(NODE) \ TREE_LANG_FLAG_1 (TEMPLATE_INFO_CHECK (NODE)) /* For a given TREE_VEC containing a template argument list, -- 2.30.2