PR c++/79519 - ICE with deleted template friend.
authorJason Merrill <jason@redhat.com>
Mon, 20 Mar 2017 20:36:46 +0000 (16:36 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 20 Mar 2017 20:36:46 +0000 (16:36 -0400)
* decl.c (grokdeclarator): Complain about misplaced function
definition using =, as well.

From-SVN: r246291

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp0x/deleted13.C [new file with mode: 0644]

index 2797f8c71574df382b3b77a905ebe3bedda927e8..428e07ccb0b081025290e7f945ac96b50e37c344 100644 (file)
@@ -1,5 +1,9 @@
 2017-03-20  Jason Merrill  <jason@redhat.com>
 
+       PR c++/79519 - ICE with deleted template friend.
+       * decl.c (grokdeclarator): Complain about misplaced function
+       definition using =, as well.
+
        PR c++/79640 - infinite recursion with generic lambda.
        * pt.c (tsubst_copy) [VAR_DECL]: Register the dummy instantiation
        before substituting its initializer.
index 0a9256680a0ec5a222df9c48e624a07b93c5e90c..516b93c3da96fd5faf3f9256f0297d5eba866623 100644 (file)
@@ -11365,9 +11365,9 @@ grokdeclarator (const cp_declarator *declarator,
       else if (TREE_CODE (type) == FUNCTION_TYPE)
        {
          if (current_class_type
-             && (!friendp || funcdef_flag))
+             && (!friendp || funcdef_flag || initialized))
            {
-             error (funcdef_flag
+             error (funcdef_flag || initialized
                     ? G_("cannot define member function %<%T::%s%> "
                          "within %<%T%>")
                     : G_("cannot declare member function %<%T::%s%> "
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted13.C b/gcc/testsuite/g++.dg/cpp0x/deleted13.C
new file mode 100644 (file)
index 0000000..f10551f
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/79519
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  template<typename> void foo();
+};
+
+struct B
+{
+  template<typename> friend void A::foo() = delete; // { dg-error "" }
+};