From a6e34898d1e8920cc68d2089e45434c9703a77d0 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 27 Apr 2018 16:56:55 +0000 Subject: [PATCH] re PR c++/84691 (internal compiler error: in poplevel_class, at cp/name-lookup.c:4430) /cp 2018-04-27 Paolo Carlini PR c++/84691 * decl.c (grokdeclarator): Clear friendp upon definition in local class definition error. /testsuite 2018-04-27 Paolo Carlini PR c++/84691 * g++.dg/cpp0x/friend3.C: New. From-SVN: r259716 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 8 +++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/friend3.C | 11 +++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/friend3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9fd52669e97..552828fa3ea 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-04-27 Paolo Carlini + + PR c++/84691 + * decl.c (grokdeclarator): Clear friendp upon definition in local + class definition error. + 2018-04-27 Jason Merrill PR c++/85545 - ICE with noexcept PMF conversion. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 55e234334ac..03bc041780f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11298,9 +11298,11 @@ grokdeclarator (const cp_declarator *declarator, if (decl_context == NORMAL) error ("friend declaration not in class definition"); if (current_function_decl && funcdef_flag) - error ("can%'t define friend function %qs in a local " - "class definition", - name); + { + error ("can%'t define friend function %qs in a local " + "class definition", name); + friendp = 0; + } } else if (ctype && sfk == sfk_conversion) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 79d712f58c2..a20bfd0c1dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-04-27 Paolo Carlini + + PR c++/84691 + * g++.dg/cpp0x/friend3.C: New. + 2018-04-27 Kyrylo Tkachov PR target/82518 diff --git a/gcc/testsuite/g++.dg/cpp0x/friend3.C b/gcc/testsuite/g++.dg/cpp0x/friend3.C new file mode 100644 index 00000000000..4432fc184df --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/friend3.C @@ -0,0 +1,11 @@ +// PR c++/84691 +// { dg-do compile { target c++11 } } + +template +struct a { + unsigned b = [] { + union { + friend void c() {} // { dg-error "local class" } + }; // { dg-error "no members" } + }; +}; -- 2.30.2