From: Kriang Lerdsuwanakij Date: Fri, 17 Oct 2003 15:41:46 +0000 (+0000) Subject: re PR c++/2513 (internal template template parameter causes ICE) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9579624e7258fc1c5cf8e79a63bbe950deae7c17;p=gcc.git re PR c++/2513 (internal template template parameter causes ICE) PR c++/2513 * decl.c (make_typename_type): Use dependent_type_p. (make_unbound_class_template): Likewise. * pt.c (instantiate_class_template): Increment processing_template_decl during substitution of template friend function. Preincrement processing_template_decl rather than postincrement. (get_mostly_instantiated_function_type): Increment processing_template_decl during partial substitution of function type. * g++.dg/template/typename5.C: New test. From-SVN: r72611 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 81730210bda..b5cba3c7aaf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,16 @@ +2003-10-17 Kriang Lerdsuwanakij + + PR c++/2513 + * decl.c (make_typename_type): Use dependent_type_p. + (make_unbound_class_template): Likewise. + * pt.c (instantiate_class_template): Increment + processing_template_decl during substitution of template friend + function. Preincrement processing_template_decl rather than + postincrement. + (get_mostly_instantiated_function_type): Increment + processing_template_decl during partial substitution of function + type. + 2003-10-15 Jan Hubicka pr c++/12574 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7b0f86847a0..227c773e1b3 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2604,7 +2604,7 @@ make_typename_type (tree context, tree name, tsubst_flags_t complain) return error_mark_node; } - if (! uses_template_parms (context) + if (!dependent_type_p (context) || currently_open_class (context)) { if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR) @@ -2663,7 +2663,7 @@ make_typename_type (tree context, tree name, tsubst_flags_t complain) /* If the CONTEXT is not a template type, then either the field is there now or its never going to be. */ - if (!uses_template_parms (context)) + if (!dependent_type_p (context)) { if (complain & tf_error) error ("no type named `%#T' in `%#T'", name, context); @@ -2692,7 +2692,7 @@ make_unbound_class_template (tree context, tree name, tsubst_flags_t complain) if (TREE_CODE (name) != IDENTIFIER_NODE) abort (); - if (!uses_template_parms (context) + if (!dependent_type_p (context) || currently_open_class (context)) { tree tmpl = NULL_TREE; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 909eede693d..ffc347c7a01 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5294,10 +5294,10 @@ instantiate_class_template (tree type) tree r; if (TREE_CODE (t) == TEMPLATE_DECL) - processing_template_decl++; + ++processing_template_decl; r = tsubst (t, args, tf_error, NULL_TREE); if (TREE_CODE (t) == TEMPLATE_DECL) - processing_template_decl--; + --processing_template_decl; set_current_access_from_decl (r); grok_special_member_properties (r); finish_member_declaration (r); @@ -5317,10 +5317,10 @@ instantiate_class_template (tree type) input_location = DECL_SOURCE_LOCATION (t); if (TREE_CODE (t) == TEMPLATE_DECL) - processing_template_decl++; + ++processing_template_decl; r = tsubst (t, args, tf_error | tf_warning, NULL_TREE); if (TREE_CODE (t) == TEMPLATE_DECL) - processing_template_decl--; + --processing_template_decl; if (TREE_CODE (r) == VAR_DECL) { tree init; @@ -5412,9 +5412,17 @@ instantiate_class_template (tree type) --processing_template_decl; } else - /* Build new DECL_FRIENDLIST. */ - add_friend (type, tsubst_friend_function (t, args), - /*complain=*/false); + { + /* Build new DECL_FRIENDLIST. */ + tree r; + + if (TREE_CODE (t) == TEMPLATE_DECL) + ++processing_template_decl; + r = tsubst_friend_function (t, args); + if (TREE_CODE (t) == TEMPLATE_DECL) + --processing_template_decl; + add_friend (type, r, /*complain=*/false); + } } } @@ -11246,9 +11254,11 @@ get_mostly_instantiated_function_type (tree decl) specialized or not. */ push_access_scope (decl); + ++processing_template_decl; /* Now, do the (partial) substitution to figure out the appropriate function type. */ fn_type = tsubst (fn_type, partial_args, tf_error, NULL_TREE); + --processing_template_decl; /* Substitute into the template parameters to obtain the real innermost set of parameters. This step is important if the diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3f00636946f..5cfe1e48523 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-10-17 Kriang Lerdsuwanakij + + PR c++/2513 + * g++.dg/template/typename5.C: New test. + 2003-10-17 Kriang Lerdsuwanakij PR c++/12369 diff --git a/gcc/testsuite/g++.dg/template/typename5.C b/gcc/testsuite/g++.dg/template/typename5.C new file mode 100644 index 00000000000..2f72b5f8601 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/typename5.C @@ -0,0 +1,19 @@ +// { dg-do compile } + +// Origin: ariels@compugen.co.il + +// PR c++/2513: typename handling when scope is dependent as +// described in DR108. + +template struct Select { + typedef int Result; +}; + +template class Pred> struct FindType { + typedef typename Select::Result Result; +}; + +template struct Int { + template struct RightSize {}; + typedef typename FindType::Result type; +};