From 8adf5b5e7b6ee28371f5eedcf2aa8c9485cffa16 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 24 Feb 1998 01:41:45 +0000 Subject: [PATCH] pt.c (instantiate_class_template): Don't instantiate if pedantic and the args use template parms. * pt.c (instantiate_class_template): Don't instantiate if pedantic and the args use template parms. * pt.c (push_tinst_level): If the instantiaton uses template parms, fail silently. * decl.c (xref_basetypes): Do call complete_type for basetypes that involve template parameters. From-SVN: r18215 --- gcc/cp/ChangeLog | 10 ++++++++++ gcc/cp/decl.c | 7 ++++--- gcc/cp/pt.c | 13 +++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 75ff86cdd05..757a1fd2389 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +Tue Feb 24 01:40:24 1998 Jason Merrill + + * pt.c (instantiate_class_template): Don't instantiate if pedantic + and the args use template parms. + + * pt.c (push_tinst_level): If the instantiaton uses template parms, + fail silently. + * decl.c (xref_basetypes): Do call complete_type for basetypes + that involve template parameters. + Tue Feb 24 00:36:43 1998 Jason Merrill * typeck2.c (process_init_constructor): Fix labeled init check. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7ba992a163e..df260a304cd 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11038,9 +11038,10 @@ xref_basetypes (code_type_node, name, ref, binfo) continue; } #if 1 - /* This code replaces similar code in layout_basetypes. */ - else if (! (current_template_parms && uses_template_parms (basetype)) - && TYPE_SIZE (complete_type (basetype)) == NULL_TREE) + /* This code replaces similar code in layout_basetypes. + We put the complete_type first for implicit `typename'. */ + else if (TYPE_SIZE (complete_type (basetype)) == NULL_TREE + && ! (current_template_parms && uses_template_parms (basetype))) { cp_error ("base class `%T' has incomplete type", basetype); continue; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c6d8f183f6a..d70bc62f27c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2749,6 +2749,12 @@ push_tinst_level (d) int line = lineno; char *file = input_filename; + /* If the instantiation in question still has unbound template parms, + we don't really care if we can't instantiate it, so just return. + This happens with base instantiation for implicit `typename'. */ + if (uses_template_parms (d)) + return 0; + error ("template instantiation depth exceeds maximum of %d", max_tinst_depth); error (" (use -ftemplate-depth-NN to increase the maximum)"); @@ -2951,6 +2957,13 @@ instantiate_class_template (type) if (t) args = get_class_bindings (TREE_VALUE (t), TREE_PURPOSE (t), args); + if (pedantic && uses_template_parms (args)) + /* If there are still template parameters amongst the args, then + we can't instantiate the type; there's no telling whether or not one + of the template parameters might eventually be instantiated to some + value that results in a specialization being used. */ + return type; + TYPE_BEING_DEFINED (type) = 1; if (! push_tinst_level (type)) -- 2.30.2