diff mbox

Fix PR c++/60064.

Message ID 1392761834-17159-1-git-send-email-adam@jessamine.co.uk
State New
Headers show

Commit Message

Adam Butcher Feb. 18, 2014, 10:17 p.m. UTC
PR c++/60064
    * parser.c (cp_parser_member_declaration): Pop fully implicit template
    scope for generic friend declarations as well as for non-friends.

    PR c++/60064
    * g++.dg/cpp1y/pr60064.C: New testcase.
---
 gcc/cp/parser.c                      |  8 +++-----
 gcc/testsuite/g++.dg/cpp1y/pr60064.C | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr60064.C

Comments

Jason Merrill Feb. 18, 2014, 10:21 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 23d54fb..9818213 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -20406,13 +20406,11 @@  cp_parser_member_declaration (cp_parser* parser)
 							      &decl_specifiers,
 							      declarator,
 							      attributes);
+		  if (parser->fully_implicit_function_template_p)
+		    decl = finish_fully_implicit_template (parser, decl);
 		  /* If the member was not a friend, declare it here.  */
 		  if (!friend_p)
-		    {
-		      if (parser->fully_implicit_function_template_p)
-			decl = finish_fully_implicit_template (parser, decl);
-		      finish_member_declaration (decl);
-		    }
+		    finish_member_declaration (decl);
 		  /* Peek at the next token.  */
 		  token = cp_lexer_peek_token (parser->lexer);
 		  /* If the next token is a semicolon, consume it.  */
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60064.C b/gcc/testsuite/g++.dg/cpp1y/pr60064.C
new file mode 100644
index 0000000..21b043d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr60064.C
@@ -0,0 +1,21 @@ 
+// PR c++/60064
+// { dg-do compile }
+// { dg-options "-std=c++1y" }
+
+class A
+{
+  int m;
+  friend void foo (auto) {}
+  friend void foo2 (auto);
+};
+
+void foo2 (auto i)
+{
+  A a;
+  a.m = i;
+}
+
+int main ()
+{
+  foo2 (7);
+}