Here, we were seeing that A<X>:: is a template specialization, so we
tried to treat it as entering the scope of A<X>.  But since A is an
alias template, that doesn't make sense.  Fixed by not considering
alias templates for this treatment.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 7fde9bb020c7be786c791e485261e28e7b0d3ccf
Author: Jason Merrill <ja...@redhat.com>
Date:   Thu Mar 23 16:21:34 2017 -0400

            PR c++/77339 - ICE with invalid use of alias template.
    
            * pt.c (lookup_template_class_1): Don't try to enter the scope of an
            alias template.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 5259dad..cbe8082 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8682,9 +8682,9 @@ lookup_template_class_1 (tree d1, tree arglist, tree 
in_decl, tree context,
          || !PRIMARY_TEMPLATE_P (gen_tmpl)
          || currently_open_class (template_type))
        {
-         tree tinfo = TYPE_TEMPLATE_INFO_MAYBE_ALIAS (template_type);
+         tree tinfo = TYPE_TEMPLATE_INFO (template_type);
 
-         if (comp_template_args (TI_ARGS (tinfo), arglist))
+         if (tinfo && comp_template_args (TI_ARGS (tinfo), arglist))
            return template_type;
        }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-58.C 
b/gcc/testsuite/g++.dg/cpp0x/alias-decl-58.C
new file mode 100644
index 0000000..0ae1c49
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-58.C
@@ -0,0 +1,7 @@
+// PR c++/77339
+// { dg-do compile { target c++11 } }
+
+template < typename > using A = int;
+
+//OK: template < typename X > A < X > a; 
+template < typename X > A < X >::a; // { dg-error "" }

Reply via email to