re PR c++/60064 ([c++1y] ICE with auto as parameter of friend function)
authorAdam Butcher <adam@jessamine.co.uk>
Tue, 18 Feb 2014 22:29:56 +0000 (22:29 +0000)
committerAdam Butcher <abutcher@gcc.gnu.org>
Tue, 18 Feb 2014 22:29:56 +0000 (22:29 +0000)
Fix PR c++/60064.

    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.

From-SVN: r207856

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

index b0fd4b7f36b0ae726269e71b7af07c21377652c4..e29e9dd0f3955339762d787979599fa542047901 100644 (file)
@@ -5,6 +5,10 @@
        scope whenever a template parameter list has been started, independent
        of whether the function call operator was well-formed or not.
 
+       PR c++/60064
+       * parser.c (cp_parser_member_declaration): Pop fully implicit template
+       scope for generic friend declarations as well as for non-friends.
+
 2014-02-12  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/60047
index 23d54fb12863d64921626a80ffd7c13b392c9c87..98182138e2414c3007cb63a45c2053ac01eb299e 100644 (file)
@@ -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.  */
index 780614cc79b8d45a2d480c87971f021f24b53942..855b0c2bc0ffb2559e8947652296bdc5c963b064 100644 (file)
@@ -9,6 +9,9 @@
        PR c++/60190
        * g++.dg/cpp1y/pr60190.C: New testcase.
 
+       PR c++/60064
+       * g++.dg/cpp1y/pr60064.C: New testcase.
+
 2014-02-18  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/60205
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60064.C b/gcc/testsuite/g++.dg/cpp1y/pr60064.C
new file mode 100644 (file)
index 0000000..21b043d
--- /dev/null
@@ -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);
+}