]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/60241 (internal compiler error: in finish_member_declaration, at cp/semanti...
authorJason Merrill <jason@redhat.com>
Fri, 1 Aug 2014 18:33:41 +0000 (14:33 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 1 Aug 2014 18:33:41 +0000 (14:33 -0400)
PR c++/60241
* pt.c (lookup_template_class_1): Update DECL_TEMPLATE_INSTANTIATIONS
of the partial instantiation, not the most general template.
(maybe_process_partial_specialization): Reassign everything on
that list.

From-SVN: r213500

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

index eda7f4e2e90bff1bf2be4d83b51acd16acbbc0d8..9c49b5c669382a6b75865fc2ddc369f55253f2d9 100644 (file)
@@ -1,3 +1,11 @@
+2014-02-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/60241
+       * pt.c (lookup_template_class_1): Update DECL_TEMPLATE_INSTANTIATIONS
+       of the partial instantiation, not the most general template.
+       (maybe_process_partial_specialization): Reassign everything on
+       that list.
+
 2014-03-05  Jason Merrill  <jason@redhat.com>
 
        PR c++/60361
index a1888921a2fa61420063010aef2e6aeeb9d0664c..a8e2cd90fce9299b168efc747fdfca193b484e49 100644 (file)
@@ -907,11 +907,13 @@ maybe_process_partial_specialization (tree type)
               t; t = TREE_CHAIN (t))
            {
              tree inst = TREE_VALUE (t);
-             if (CLASSTYPE_TEMPLATE_SPECIALIZATION (inst))
+             if (CLASSTYPE_TEMPLATE_SPECIALIZATION (inst)
+                 || !COMPLETE_OR_OPEN_TYPE_P (inst))
                {
                  /* We already have a full specialization of this partial
-                    instantiation.  Reassign it to the new member
-                    specialization template.  */
+                    instantiation, or a full specialization has been
+                    looked up but not instantiated.  Reassign it to the
+                    new member specialization template.  */
                  spec_entry elt;
                  spec_entry *entry;
                  void **slot;
@@ -930,7 +932,7 @@ maybe_process_partial_specialization (tree type)
                  *entry = elt;
                  *slot = entry;
                }
-             else if (COMPLETE_OR_OPEN_TYPE_P (inst))
+             else
                /* But if we've had an implicit instantiation, that's a
                   problem ([temp.expl.spec]/6).  */
                error ("specialization %qT after instantiation %qT",
@@ -7455,7 +7457,7 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
        }
 
       /* Let's consider the explicit specialization of a member
-         of a class template specialization that is implicitely instantiated,
+         of a class template specialization that is implicitly instantiated,
         e.g.:
             template<class T>
             struct S
@@ -7553,9 +7555,9 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
 
       /* Note this use of the partial instantiation so we can check it
         later in maybe_process_partial_specialization.  */
-      DECL_TEMPLATE_INSTANTIATIONS (templ)
+      DECL_TEMPLATE_INSTANTIATIONS (found)
        = tree_cons (arglist, t,
-                    DECL_TEMPLATE_INSTANTIATIONS (templ));
+                    DECL_TEMPLATE_INSTANTIATIONS (found));
 
       if (TREE_CODE (template_type) == ENUMERAL_TYPE && !is_dependent_type)
        /* Now that the type has been registered on the instantiations
diff --git a/gcc/testsuite/g++.dg/template/memclass5.C b/gcc/testsuite/g++.dg/template/memclass5.C
new file mode 100644 (file)
index 0000000..eb32f13
--- /dev/null
@@ -0,0 +1,26 @@
+// PR c++/60241
+
+template <typename T>
+struct x
+{
+    template <typename U>
+    struct y
+    {
+        typedef T result2;
+    };
+
+    typedef y<int> zy;
+};
+
+template<>
+template<class T>
+struct x<int>::y
+{
+    typedef double result2;
+};
+
+int main()
+{
+    x<int>::zy::result2 xxx;
+    x<int>::y<int>::result2 xxx2;
+}