re PR c++/84691 (internal compiler error: in poplevel_class, at cp/name-lookup.c...
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 27 Apr 2018 16:56:55 +0000 (16:56 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 27 Apr 2018 16:56:55 +0000 (16:56 +0000)
/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.

From-SVN: r259716

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

index 9fd52669e97e510bfc3506801c1af8a132aba5e7..552828fa3eaf66d9cf60adaa7d72fe2ad0b0c5e9 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84691
+       * decl.c (grokdeclarator): Clear friendp upon definition in local
+       class definition error.
+
 2018-04-27  Jason Merrill  <jason@redhat.com>
 
        PR c++/85545 - ICE with noexcept PMF conversion.
index 55e234334ac626e25ff5144b81cca6ba8e5dcaec..03bc041780fc5103c61f91f8ce272244b8536088 100644 (file)
@@ -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 79d712f58c20a1d1768d1fb95c5aeeea0f0a9aa3..a20bfd0c1dc17831a994c3afda10766fed39046f 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84691
+       * g++.dg/cpp0x/friend3.C: New.
+
 2018-04-27  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        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 (file)
index 0000000..4432fc1
--- /dev/null
@@ -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" }
+  };
+};