re PR c++/59766 (c++1y: declaring friend function with 'auto' return type deduction...
authorDavid Krauss <david_work@me.com>
Tue, 14 Apr 2015 15:29:27 +0000 (15:29 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 14 Apr 2015 15:29:27 +0000 (11:29 -0400)
PR c++/59766
* decl.c (grokdeclarator): Do not flag friends with deduced return.

From-SVN: r222095

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp1y/auto-fn26.C [new file with mode: 0644]

index 2e43e4d100ef52acf154b9317904022f3b3acc49..10df58f0bee109141059b53838b09584aa3aa927 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-14  David Krauss  <david_work@me.com>
+
+       PR c++/59766
+       * decl.c (grokdeclarator): Do not flag friends with deduced return.
+
 2015-04-14  Momchil Velikov  <momchil.velikov@gmail.com>
            Jason Merrill  <jason@redhat.com>
 
index c4731ae2416e61e282447da957370960946fd70b..c8323b0e9a49573f08646fb48ea1e3e29e4f67f6 100644 (file)
@@ -10628,7 +10628,7 @@ grokdeclarator (const cp_declarator *declarator,
       }
     else if (decl_context == FIELD)
       {
-       if (!staticp && TREE_CODE (type) != METHOD_TYPE
+       if (!staticp && !friendp && TREE_CODE (type) != METHOD_TYPE
            && type_uses_auto (type))
          {
            error ("non-static data member declared %<auto%>");
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn26.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn26.C
new file mode 100644 (file)
index 0000000..17f232f
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/59766
+// { dg-do compile { target c++14 } }
+
+struct T {
+  friend auto f() { }
+};