diff mbox series

[PR,c++/95263] Revert alias template change

Message ID 89f54648-ab7c-7bf9-145d-eaae9fe3455c@acm.org
State New
Headers show
Series [PR,c++/95263] Revert alias template change | expand

Commit Message

Nathan Sidwell May 27, 2020, 1:53 p.m. UTC
Sadly my attempt to make some aliast template construction immutable 
doesn't always apply.  Reverting that patch and I guess more work needed 
on modules :(

nathan
diff mbox series

Patch

2020-05-27  Nathan Sidwell  <nathan@acm.org>

	PR c++/95263, revert 74744bb1f2847b5b9ce3e97e0fec9c23bb0e499f
	* pt.c (lookup_template_class_1): Restore alias template mutation.

diff --git i/gcc/cp/pt.c w/gcc/cp/pt.c
index c17a038c6d0..4d9651acee6 100644
--- i/gcc/cp/pt.c
+++ w/gcc/cp/pt.c
@@ -10062,21 +10062,8 @@  lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
 	    }
 	}
 
-      /* Build template info for the new specialization.  This can
-	 overwrite the existing TEMPLATE_INFO for T (that points to
-	 its instantiated TEMPLATE_DECL), with this one that points to
-	 the most general template, but that's what we want.  */
-
-      if (TYPE_ALIAS_P (t))
-	{
-	  /* This should already have been constructed during
-	     instantiation of the alias decl.  */
-	  tree ti = DECL_TEMPLATE_INFO (TYPE_NAME (t));
-	  gcc_checking_assert (template_args_equal (TI_ARGS (ti), arglist)
-			       && TI_TEMPLATE (ti) == found);
-	}
-      else
-	SET_TYPE_TEMPLATE_INFO (t, build_template_info (found, arglist));
+      // Build template info for the new specialization.
+      SET_TYPE_TEMPLATE_INFO (t, build_template_info (found, arglist));
 
       elt.spec = t;
       slot = type_specializations->find_slot_with_hash (&elt, hash, INSERT);
diff --git c/gcc/testsuite/g++.dg/template/pr95263.C w/gcc/testsuite/g++.dg/template/pr95263.C
new file mode 100644
index 00000000000..08a1b8730c0
--- /dev/null
+++ w/gcc/testsuite/g++.dg/template/pr95263.C
@@ -0,0 +1,23 @@ 
+// { dg-do compile { target c++11 } }
+// PR C++/95263
+// ICE on alias template instantiation
+
+template <typename> class TPL {
+  template <int> using INT = int;
+};
+
+template <typename T> class Klass
+{
+public:
+  template <int I> using ALIAS = typename TPL<T>::INT<I>;
+
+  template <int> static void FUNC (); // OK
+
+  template <int I, typename> static ALIAS<I> FUNC (); // SFINAE ICE
+};
+
+void Fn ()
+{
+  Klass<int>::FUNC<0> ();
+}
+