]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/13289 (ICE in regenerate_decl_from_template on recursive template)
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Mon, 12 Jan 2004 20:10:19 +0000 (20:10 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Mon, 12 Jan 2004 20:10:19 +0000 (12:10 -0800)
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  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

        PR c++/13289
        * g++.dg/template/instantiate6.C: New test.

From-SVN: r75752

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/instantiate6.C [new file with mode: 0644]

index 48d831ecb63fa9c8bccc01f20535fcefd61e991f..109dc83fb2fe8cc603fd10b728cacac98d8d5171 100644 (file)
@@ -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
index 473b6fe03bdff0ceb0c4d9e340c488c4f17cb2dc..81dd711e033770de8c683acc1f98aa6202bd4a4e 100644 (file)
@@ -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));
index efe747befe721e7bf930d31d48fab467b1da4bff..0c67ba101b01fa77241416753eac258a3e2985a4 100644 (file)
@@ -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 (file)
index 0000000..d5d712e
--- /dev/null
@@ -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>;
+