diff options
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/instantiate6.C | 16 |
4 files changed, 36 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 48d831e..109dc83 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-01-12 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/13289 + * pt.c (instantiate_decl): Set DECL_TEMPLATE_INSTANTIATED before + calling regenerate_decl_from_template. + 2004-01-12 Scott Brumbaugh <scottb.lists@verizon.net> PR c++/4100 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 473b6fe..81dd711 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11016,6 +11016,10 @@ instantiate_decl (tree d, int 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); @@ -11052,13 +11056,14 @@ instantiate_decl (tree d, int 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)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index efe747b..0c67ba1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-01-12 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/13289 + * g++.dg/template/instantiate6.C: New test. + 2004-01-12 Roger Sayle <roger@eyesopen.com> PR middle-end/11397 diff --git a/gcc/testsuite/g++.dg/template/instantiate6.C b/gcc/testsuite/g++.dg/template/instantiate6.C new file mode 100644 index 0000000..d5d712e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/instantiate6.C @@ -0,0 +1,16 @@ +// { dg-do compile } + +// Origin: gianni@mariani.ws +// Wolfgang Bangerth <bangerth@ticam.utexas.edu> + +// PR c++/13289: ICE recursively instantiate static member data. + +template <int N> struct S { + static const int C; +}; + +template <int N> +const int S<N>::C = S<(N+1)%2>::C; + +template struct S<1>; + |