From 574817a219778a2800ff781cb583205b391821f0 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 1 Mar 1998 21:07:22 +0000 Subject: [PATCH] pt.c (instantiate_class_template): Don't mess with friends if our type uses template parms. * pt.c (instantiate_class_template): Don't mess with friends if our type uses template parms. From-SVN: r18350 --- gcc/cp/ChangeLog | 5 +++ gcc/cp/pt.c | 105 +++++++++++++++++++++++------------------------ 2 files changed, 56 insertions(+), 54 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c1125778e5c..cf011cc3967 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +Sun Mar 1 21:06:37 1998 Jason Merrill + + * pt.c (instantiate_class_template): Don't mess with friends if + our type uses template parms. + Sat Feb 28 12:06:44 1998 Jason Merrill * parse.y (nested_name_specifier): Use explicit_template_type. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 015604f7478..027700e4b93 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3153,74 +3153,71 @@ instantiate_class_template (type) grok_op_properties (t, DECL_VIRTUAL_P (t), 0); } - /* Construct the DECL_FRIENDLIST for the new class type. */ - typedecl = TYPE_MAIN_DECL (type); - for (t = DECL_FRIENDLIST (TYPE_MAIN_DECL (pattern)); - t != NULL_TREE; - t = TREE_CHAIN (t)) + if (! uses_template_parms (type)) { - tree friends; + /* Construct the DECL_FRIENDLIST for the new class type. */ + typedecl = TYPE_MAIN_DECL (type); + for (t = DECL_FRIENDLIST (TYPE_MAIN_DECL (pattern)); + t != NULL_TREE; + t = TREE_CHAIN (t)) + { + tree friends; - DECL_FRIENDLIST (typedecl) - = tree_cons (TREE_PURPOSE (t), NULL_TREE, - DECL_FRIENDLIST (typedecl)); + DECL_FRIENDLIST (typedecl) + = tree_cons (TREE_PURPOSE (t), NULL_TREE, + DECL_FRIENDLIST (typedecl)); - for (friends = TREE_VALUE (t); - friends != NULL_TREE; - friends = TREE_CHAIN (friends)) - { - if (TREE_PURPOSE (friends) == error_mark_node) + for (friends = TREE_VALUE (t); + friends != NULL_TREE; + friends = TREE_CHAIN (friends)) { - TREE_VALUE (DECL_FRIENDLIST (typedecl)) - = tree_cons (error_mark_node, - tsubst_friend_function (TREE_VALUE (friends), - args), - TREE_VALUE (DECL_FRIENDLIST (typedecl))); - } - else - { - TREE_VALUE (DECL_FRIENDLIST (typedecl)) - = tree_cons (tsubst (TREE_PURPOSE (friends), args, NULL_TREE), - NULL_TREE, - TREE_VALUE (DECL_FRIENDLIST (typedecl))); + if (TREE_PURPOSE (friends) == error_mark_node) + { + TREE_VALUE (DECL_FRIENDLIST (typedecl)) + = tree_cons (error_mark_node, + tsubst_friend_function (TREE_VALUE (friends), + args), + TREE_VALUE (DECL_FRIENDLIST (typedecl))); + } + else + { + TREE_VALUE (DECL_FRIENDLIST (typedecl)) + = tree_cons (tsubst (TREE_PURPOSE (friends), args, NULL_TREE), + NULL_TREE, + TREE_VALUE (DECL_FRIENDLIST (typedecl))); + } } } - } - { - tree d = CLASSTYPE_FRIEND_CLASSES (type) - = tsubst (CLASSTYPE_FRIEND_CLASSES (pattern), args, NULL_TREE); + t = CLASSTYPE_FRIEND_CLASSES (type) + = tsubst (CLASSTYPE_FRIEND_CLASSES (pattern), args, NULL_TREE); - /* This does injection for friend classes. */ - for (; d; d = TREE_CHAIN (d)) - TREE_VALUE (d) = xref_tag_from_type (TREE_VALUE (d), NULL_TREE, 1); + /* This does injection for friend classes. */ + for (; t; t = TREE_CHAIN (t)) + TREE_VALUE (t) = xref_tag_from_type (TREE_VALUE (t), NULL_TREE, 1); - /* This does injection for friend functions. */ - if (!processing_template_decl) - { - d = tsubst (DECL_TEMPLATE_INJECT (template), args, NULL_TREE); + /* This does injection for friend functions. */ + if (!processing_template_decl) + { + t = tsubst (DECL_TEMPLATE_INJECT (template), args, NULL_TREE); - for (; d; d = TREE_CHAIN (d)) - { - tree t = TREE_VALUE (d); + for (; t; t = TREE_CHAIN (t)) + { + tree d = TREE_VALUE (t); - if (TREE_CODE (t) == TYPE_DECL) - /* Already injected. */; - else - pushdecl (t); - } - } - } + if (TREE_CODE (d) == TYPE_DECL) + /* Already injected. */; + else + pushdecl (d); + } + } - if (! uses_template_parms (type)) - { - tree tmp; - for (tmp = TYPE_FIELDS (type); tmp; tmp = TREE_CHAIN (tmp)) - if (TREE_CODE (tmp) == FIELD_DECL) + for (t = TYPE_FIELDS (type); t; t = TREE_CHAIN (t)) + if (TREE_CODE (t) == FIELD_DECL) { - TREE_TYPE (tmp) = complete_type (TREE_TYPE (tmp)); - require_complete_type (tmp); + TREE_TYPE (t) = complete_type (TREE_TYPE (t)); + require_complete_type (t); } type = finish_struct_1 (type, 0); -- 2.30.2