Here the problem was just that we were failing to check complain for
the missing braces warning.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 9d4ef5496bdd42e5986a06089901631983b04846
Author: Jason Merrill <ja...@redhat.com>
Date:   Fri Jul 22 14:42:53 2016 -0400

        PR c++/71515 - typename in partial specialization
    
        * pt.c (resolve_typename_type): Check currently_open_class later.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 3ee53d1..7758f44 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -23675,10 +23675,6 @@ resolve_typename_type (tree type, bool only_current_p)
      resolving the name.  */
   if (TREE_CODE (scope) == TEMPLATE_TYPE_PARM)
     return type;
-  /* If the SCOPE is not the current instantiation, there's no reason
-     to look inside it.  */
-  if (only_current_p && !currently_open_class (scope))
-    return type;
   /* If this is a typedef, we don't want to look inside (c++/11987).  */
   if (typedef_variant_p (type))
     return type;
@@ -23693,6 +23689,10 @@ resolve_typename_type (tree type, bool only_current_p)
     /* scope is a partial instantiation, so we can't do the lookup or we
        will lose the template arguments.  */
     return type;
+  /* If the SCOPE is not the current instantiation, there's no reason
+     to look inside it.  */
+  if (only_current_p && !currently_open_class (scope))
+    return type;
   /* Enter the SCOPE so that name lookup will be resolved as if we
      were in the class definition.  In particular, SCOPE will no
      longer be considered a dependent type.  */
diff --git a/gcc/testsuite/g++.dg/template/typename22.C 
b/gcc/testsuite/g++.dg/template/typename22.C
new file mode 100644
index 0000000..b5dc1b5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/typename22.C
@@ -0,0 +1,8 @@
+// PR c++/71515
+
+template < typename, typename = int > struct A;
+
+template < typename T > struct A < T, typename A < T >::type >
+{
+  A < int > *a;
+};

Reply via email to