From 18f73c5f243f55cab6413674ee7eb35db56932ad Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 20 Mar 2017 16:36:46 -0400 Subject: [PATCH] PR c++/79519 - ICE with deleted template friend. * decl.c (grokdeclarator): Complain about misplaced function definition using =, as well. From-SVN: r246291 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl.c | 4 ++-- gcc/testsuite/g++.dg/cpp0x/deleted13.C | 12 ++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/deleted13.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2797f8c7157..428e07ccb0b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-03-20 Jason Merrill + 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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 0a9256680a0..516b93c3da9 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 index 00000000000..f10551f9666 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/deleted13.C @@ -0,0 +1,12 @@ +// PR c++/79519 +// { dg-do compile { target c++11 } } + +struct A +{ + template void foo(); +}; + +struct B +{ + template friend void A::foo() = delete; // { dg-error "" } +}; -- 2.30.2