diff mbox

[C++] PR 59482

Message ID CAFk2RUbqm4X5o9K95JZWHYMWiExtuVRCXvKjbreWf86jw4=2YQ@mail.gmail.com
State New
Headers show

Commit Message

Ville Voutilainen Jan. 21, 2014, 3:23 p.m. UTC
As analysed in the bug report, the scope for the accessibility
check was incorrect, and hence the friend was not allowed access.
Fixed by pushing into the class scope before parsing the
base-clause, and popping afterwards to let the surrounding
nested-name-specifier popping work correctly.

Tested on x86_64-linux.

Comments

Jason Merrill Jan. 21, 2014, 3:24 p.m. UTC | #1
OK, thanks.

Jason
Paolo Carlini Jan. 22, 2014, 5:39 p.m. UTC | #2
On 01/21/2014 04:24 PM, Jason Merrill wrote:
> OK, thanks.
I don't think Ville has Write After Approval, thus I'm going to commit 
this on his behalf.

Thanks,
Paolo.
Ville Voutilainen Jan. 22, 2014, 10:38 p.m. UTC | #3
On 22 January 2014 19:39, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> On 01/21/2014 04:24 PM, Jason Merrill wrote:
>>
>> OK, thanks.
>
> I don't think Ville has Write After Approval, thus I'm going to commit this
> on his behalf.


Oh, I was expecting Jason would do that. Note that Marek Polacek pointed
out two formatting issues:
- comments should have full stop and two spaces at the end
- also two spaces before <e-mail> in the ChangeLog
Paolo Carlini Jan. 23, 2014, 9:39 a.m. UTC | #4
Hi,

On 01/22/2014 11:38 PM, Ville Voutilainen wrote:
> Oh, I was expecting Jason would do that. Note that Marek Polacek pointed
> out two formatting issues:
> - comments should have full stop and two spaces at the end
Yes, will fix in my next commit touching that file.
> - also two spaces before <e-mail> in the ChangeLog
I took care of this when I applied the patch.

Thanks,
Paolo.
diff mbox

Patch

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index c3016bc..3bc943b 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -19845,7 +19845,17 @@  cp_parser_class_head (cp_parser* parser,
 
   /* Get the list of base-classes, if there is one.  */
   if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
-    bases = cp_parser_base_clause (parser);
+    {
+      /* PR59482: enter the class scope so that base-specifiers are looked
+	 up correctly */
+      if (type)
+	pushclass (type);
+      bases = cp_parser_base_clause (parser);
+      /* PR59482: get out of the previously pushed class scope so that the
+	 subsequent pops pop the right thing */
+      if (type)
+	popclass ();
+    }
   else
     bases = NULL_TREE;
 
diff --git a/gcc/testsuite/g++.dg/pr59482.C b/gcc/testsuite/g++.dg/pr59482.C
new file mode 100644
index 0000000..bde8329
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr59482.C
@@ -0,0 +1,7 @@ 
+/* { dg-do compile } */
+class aa { 
+    friend class cc; 
+    class bb {}; 
+}; 
+
+class cc : aa::bb {};