Fix PR c++/60052 and PR c++/60053.
authorAdam Butcher <adam@jessamine.co.uk>
Fri, 21 Feb 2014 07:47:55 +0000 (07:47 +0000)
committerAdam Butcher <abutcher@gcc.gnu.org>
Fri, 21 Feb 2014 07:47:55 +0000 (07:47 +0000)
PR c++/60052
PR c++/60053
* parser.c (cp_parser_parameter_declaration_list): Correctly reset
implicit_template_scope upon leaving an out-of-line generic member
function definition.

PR c++/60052
PR c++/60053
* g++.dg/cpp1y/pr60052.C: New testcase.
* g++.dg/cpp1y/pr60053.C: New testcase.

From-SVN: r207980

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/pr60052.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/pr60053.C [new file with mode: 0644]

index 602ab94..7d4af6d 100644 (file)
@@ -1,3 +1,11 @@
+2014-02-21  Adam Butcher  <adam@jessamine.co.uk>
+
+       PR c++/60052
+       PR c++/60053
+       * parser.c (cp_parser_parameter_declaration_list): Correctly reset
+       implicit_template_scope upon leaving an out-of-line generic member
+       function definition.
+
 2014-02-20  Kai Tietz  <ktietz@redhat.com>
 
        PR c++/58873
index 4673f78..1e4e3df 100644 (file)
@@ -18372,11 +18372,21 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error)
   parser->in_unbraced_linkage_specification_p
     = saved_in_unbraced_linkage_specification_p;
 
+  /* Reset implicit_template_scope if we are about to leave the function
+     parameter list that introduced it.  Note that for out-of-line member
+     definitions, there will be one or more class scopes before we get to
+     the template parameter scope.  */
+
   if (cp_binding_level *its = parser->implicit_template_scope)
-    if (current_binding_level->level_chain == its)
+    if (cp_binding_level *maybe_its = current_binding_level->level_chain)
       {
-       parser->implicit_template_parms = 0;
-       parser->implicit_template_scope = 0;
+       while (maybe_its->kind == sk_class)
+         maybe_its = maybe_its->level_chain;
+       if (maybe_its == its)
+         {
+           parser->implicit_template_parms = 0;
+           parser->implicit_template_scope = 0;
+         }
       }
 
   return parameters;
index ec294e7..df82431 100644 (file)
@@ -1,3 +1,10 @@
+2014-02-21  Adam Butcher  <adam@jessamine.co.uk>
+
+       PR c++/60052
+       PR c++/60053
+       * g++.dg/cpp1y/pr60052.C: New testcase.
+       * g++.dg/cpp1y/pr60053.C: New testcase.
+
 2014-02-21  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/60286
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60052.C b/gcc/testsuite/g++.dg/cpp1y/pr60052.C
new file mode 100644 (file)
index 0000000..191e5ac
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/60052
+// { dg-do compile }
+// { dg-options "-std=c++1y" }
+
+struct A
+{
+  void foo(auto);
+};
+
+void A::foo(auto) {}
+
+struct B
+{
+  void bar(auto);
+};
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60053.C b/gcc/testsuite/g++.dg/cpp1y/pr60053.C
new file mode 100644 (file)
index 0000000..345a9b8
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/60053
+// { dg-do compile }
+// { dg-options "-std=c++1y" }
+
+struct A
+{
+  void foo(auto);
+};
+
+void A::foo(auto) {}
+
+template<typename> struct B
+{
+  template<typename T> void bar(auto);
+};