From 70c21feeb2146432142c65c85f5112267d2085c6 Mon Sep 17 00:00:00 2001 From: Kriang Lerdsuwanakij Date: Wed, 21 Jan 2004 03:26:06 +0000 Subject: [PATCH] re PR c++/13289 (ICE in regenerate_decl_from_template on recursive template) 2004-01-20 Kriang Lerdsuwanakij PR c++/13289 * pt.c (instantiate_decl): Set DECL_TEMPLATE_INSTANTIATED before calling regenerate_decl_from_template. From-SVN: r76255 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 17 +++++++++-------- gcc/testsuite/g++.dg/template/instantiate6.C | 3 +-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2b88ca0304f8..04fe29e32f72 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-01-20 Kriang Lerdsuwanakij + + PR c++/13289 + * pt.c (instantiate_decl): Set DECL_TEMPLATE_INSTANTIATED before + calling regenerate_decl_from_template. + 2004-01-14 Gabriel Dos Reis Backport from mainline diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3000847879e5..e64ed166b3e3 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10449,6 +10449,10 @@ instantiate_decl (d, defer_ok) if (need_push) push_to_top_level (); + /* Mark D as instantiated so that recursive calls to + instantiate_decl do not try to instantiate it again. */ + DECL_TEMPLATE_INSTANTIATED (d) = 1; + /* Regenerate the declaration in case the template has been modified by a subsequent redeclaration. */ regenerate_decl_from_template (d, td); @@ -10485,13 +10489,14 @@ instantiate_decl (d, defer_ok) instantiation. There, we cannot implicitly instantiate a defined static data member in more than one translation unit, so import_export_decl marks the declaration as - external; we must rely on explicit instantiation. */ + external; we must rely on explicit instantiation. + + Reset instantiated marker to make sure that later + explicit instantiation will be processed. */ + DECL_TEMPLATE_INSTANTIATED (d) = 0; } else { - /* Mark D as instantiated so that recursive calls to - instantiate_decl do not try to instantiate it again. */ - DECL_TEMPLATE_INSTANTIATED (d) = 1; /* This is done in analogous to `start_decl'. It is required for correct access checking. */ push_nested_class (DECL_CONTEXT (d), 2); @@ -10512,10 +10517,6 @@ instantiate_decl (d, defer_ok) { htab_t saved_local_specializations; - /* Mark D as instantiated so that recursive calls to - instantiate_decl do not try to instantiate it again. */ - DECL_TEMPLATE_INSTANTIATED (d) = 1; - /* Save away the current list, in case we are instantiating one template from within the body of another. */ saved_local_specializations = local_specializations; diff --git a/gcc/testsuite/g++.dg/template/instantiate6.C b/gcc/testsuite/g++.dg/template/instantiate6.C index d5d712ee0912..895e6d8e5053 100644 --- a/gcc/testsuite/g++.dg/template/instantiate6.C +++ b/gcc/testsuite/g++.dg/template/instantiate6.C @@ -1,7 +1,7 @@ // { dg-do compile } // Origin: gianni@mariani.ws -// Wolfgang Bangerth +// Wolfgang Bangerth // PR c++/13289: ICE recursively instantiate static member data. @@ -13,4 +13,3 @@ template const int S::C = S<(N+1)%2>::C; template struct S<1>; - -- 2.47.2