OSDN Git Service

* pt.c (push_template_decl_real): Use template declaration from
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 30 Aug 1999 05:22:45 +0000 (05:22 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 30 Aug 1999 05:22:45 +0000 (05:22 +0000)
class type if it exists.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@28978 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.ns/template14.C [new file with mode: 0644]

index 0fa5c60..4a8fd5a 100644 (file)
@@ -1,3 +1,8 @@
+1999-08-29  Alex Samuel  <samuel@codesourcery.com>
+
+       * pt.c (push_template_decl_real): Use template declaration from
+       class type if it exists.
+
 1999-08-29  Mark Mitchell  <mark@codesourcery.com>
 
        * cp-tree.h (TYPE_NEEDS_CONSTRUCTING): Remove #if 0'd definition.
index e321c34..ee6f85a 100644 (file)
@@ -2461,6 +2461,22 @@ push_template_decl_real (decl, is_friend)
          && DECL_TEMPLATE_INFO (decl)
          && DECL_TI_TEMPLATE (decl))
        tmpl = DECL_TI_TEMPLATE (decl);
+      /* If DECL is a TYPE_DECL for a class-template, then there won't
+        be DECL_LANG_SPECIFIC.  The information equivalent to
+        DECL_TEMPLATE_INFO is found in TYPE_TEMPLATE_INFO instead.  */
+      else if (DECL_IMPLICIT_TYPEDEF_P (decl) 
+              && TYPE_TEMPLATE_INFO (TREE_TYPE (decl))
+              && TYPE_TI_TEMPLATE (TREE_TYPE (decl)))
+       {
+         /* Since a template declaration already existed for this
+            class-type, we must be redeclaring it here.  Make sure
+            that the redeclaration is legal.  */
+         redeclare_class_template (TREE_TYPE (decl),
+                                   current_template_parms);
+         /* We don't need to create a new TEMPLATE_DECL; just use the
+            one we already had.  */
+         tmpl = TYPE_TI_TEMPLATE (TREE_TYPE (decl));
+       }
       else
        {
          tmpl = build_template_decl (decl, current_template_parms);
diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template14.C b/gcc/testsuite/g++.old-deja/g++.ns/template14.C
new file mode 100644 (file)
index 0000000..90e5312
--- /dev/null
@@ -0,0 +1,14 @@
+// Build don't link:
+// Origin: Alex Samuel <samuel@codesourcery.com>
+
+namespace Outer 
+{
+template <class T> class Inner;
+}
+
+template <class T>
+class Outer::Inner  
+{
+public:
+  Inner ();
+};