[C++] PR 84691 ("[6/7/8/9 Regression] internal compiler error: in poplevel_class...")

Message ID bb8bb182-a672-ce0a-4d7a-0280f46a9104@oracle.com
State New
Headers show
Series
  • [C++] PR 84691 ("[6/7/8/9 Regression] internal compiler error: in poplevel_class...")
Related show

Commit Message

Paolo Carlini April 27, 2018, 9:33 a.m.
Hi,

this small error-recovery issue remained in my todo list of 8 
regressions: just clear the friendp flag in this case too - like we do a 
few lines above for virtual declarations - and avoid problems later. 
Tested x86_64-linux.

Thanks, Paolo.

////////////////
/cp
2018-04-27  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84691
	* decl.c (grokdeclarator): Clear friendp upon definition in local
	class definition error.

/testsuite
2018-04-27  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84691
	* g++.dg/cpp0x/friend3.C: New.

Comments

Jason Merrill April 27, 2018, 4:40 p.m. | #1
OK.

On Fri, Apr 27, 2018 at 5:33 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,

>

> this small error-recovery issue remained in my todo list of 8 regressions:

> just clear the friendp flag in this case too - like we do a few lines above

> for virtual declarations - and avoid problems later. Tested x86_64-linux.

>

> Thanks, Paolo.

>

> ////////////////

>

Patch

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 259697)
+++ cp/decl.c	(working copy)
@@ -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)
 	      {
Index: testsuite/g++.dg/cpp0x/friend3.C
===================================================================
--- testsuite/g++.dg/cpp0x/friend3.C	(nonexistent)
+++ testsuite/g++.dg/cpp0x/friend3.C	(working copy)
@@ -0,0 +1,11 @@ 
+// PR c++/84691
+// { dg-do compile { target c++11 } }
+
+template<typename>
+struct a {
+  unsigned b = [] {
+    union {
+      friend void c() {}  // { dg-error "local class" }
+    };  // { dg-error "no members" }
+  };
+};