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 2797f8c..428e07c 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 0a92566..516b93c 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 "" }
+};