Hi,

in this regression we have an infinite recursion affecting the same_type_p call at parser.c:25125 which I added in the patch for c++/38313. The issue is that for, eg, the testcase at issue, we are passing a TYPENAME_TYPE to same_type_p. I think we can simply handle the problem by checking first that we have a CLASS_TYPE_P as TREE_TYPE (type_decl). Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////////////
/cp
2016-04-12  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/70635
        * parser.c (cp_parser_constructor_declarator_p): Only use same_type_p
        for true CLASS_TYPE_P (TREE_TYPE (type_decl)).

/testsuite
2016-04-12  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/70635
        * g++.dg/parse/pr70635.C: New.
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 234874)
+++ cp/parser.c (working copy)
@@ -25118,8 +25122,9 @@ cp_parser_constructor_declarator_p (cp_parser *par
       constructor_p = (!cp_parser_error_occurred (parser)
                       && (outside_class_specifier_p
                           || type_decl == error_mark_node
-                          || same_type_p (current_class_type,
-                                          TREE_TYPE (type_decl))));
+                          || (CLASS_TYPE_P (TREE_TYPE (type_decl))
+                              && same_type_p (current_class_type,
+                                              TREE_TYPE (type_decl)))));
 
       /* If we're still considering a constructor, we have to see a `(',
         to begin the parameter-declaration-clause, followed by either a
Index: testsuite/g++.dg/parse/pr70635.C
===================================================================
--- testsuite/g++.dg/parse/pr70635.C    (revision 0)
+++ testsuite/g++.dg/parse/pr70635.C    (working copy)
@@ -0,0 +1,23 @@
+// PR c++/70635
+// { dg-options "-fpermissive -w" }
+
+template < typename T > 
+struct A
+{
+  struct B;
+  typedef typename B::type type;
+};
+
+template < typename T > 
+struct A < T >::B
+{
+  typedef typename A < type >::type type;
+  type Foo ();
+};
+
+template < typename T > 
+typename A < T >::B::type
+A < T >::B::Foo ()
+{
+  return 0;
+}

Reply via email to