]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/86171 - ICE with recursive alias instantiation.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Jun 2018 18:16:38 +0000 (18:16 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Jun 2018 18:16:38 +0000 (18:16 +0000)
* pt.c (tsubst_decl): Handle recursive alias instantiation.

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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/alias-decl-65.C [new file with mode: 0644]

index c3b5bc628b0c6c07cf30e224f56db9814f9ca858..b1a449f91e2dc8c53df1a0fd7befc9874a594c4b 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-18  Jason Merrill  <jason@redhat.com>
+
+       PR c++/86171 - ICE with recursive alias instantiation.
+       * pt.c (tsubst_decl): Handle recursive alias instantiation.
+
 2018-06-18  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * decl.c (duplicate_decls): Consistently use DECL_SOURCE_LOCATION
index 4ee84b201e9e9f5d27e37f4d8ca2b90d052a8c87..6e590d4d3429aba042d4cd83d18d3e6e992e2704 100644 (file)
@@ -13639,7 +13639,6 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
          }
 
        /* Create a new node for the specialization we need.  */
-       r = copy_decl (t);
        if (type == NULL_TREE)
          {
            if (is_typedef_decl (t))
@@ -13664,7 +13663,16 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
                  sub_args = strip_innermost_template_args (args, extra);
              }
            type = tsubst (type, sub_args, complain, in_decl);
+           /* Substituting the type might have recursively instantiated this
+              same alias (c++/86171).  */
+           if (gen_tmpl && DECL_ALIAS_TEMPLATE_P (gen_tmpl)
+               && (spec = retrieve_specialization (gen_tmpl, argvec, hash)))
+             {
+               r = spec;
+               break;
+             }
          }
+       r = copy_decl (t);
        if (VAR_P (r))
          {
            DECL_INITIALIZED_P (r) = 0;
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-65.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-65.C
new file mode 100644 (file)
index 0000000..e320f3e
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/86171
+// { dg-do compile { target c++11 } }
+
+template <class> struct A;
+template <class T> using B = typename A<T>::X;
+template <class T> struct A {
+  typedef int X;
+  typedef B<T> U;
+};
+B<short> b;