public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/79401 (protected inherited constructor)
@ 2017-02-10 18:24 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2017-02-10 18:24 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 121 bytes --]

For a protected ctor, we need to adjust the access path, not clobber it.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 79401.diff --]
[-- Type: text/plain, Size: 1318 bytes --]

commit d065eb77265df02c1f77fc9ea78b09b731c9fa0c
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Feb 10 12:15:42 2017 -0500

            PR c++/79401 - protected inherited constructor
    
            * call.c (enforce_access): For inheriting constructor, find a base
            binfo in the path we already have.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 6533214..718438c 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6420,7 +6420,8 @@ enforce_access (tree basetype_path, tree decl, tree diag_decl,
 	 accessible when used to construct an object of the corresponding base
 	 class.  */
       decl = strip_inheriting_ctors (decl);
-      basetype_path = TYPE_BINFO (DECL_CONTEXT (decl));
+      basetype_path = lookup_base (basetype_path, DECL_CONTEXT (decl),
+				   ba_any, NULL, complain);
     }
 
   if (!accessible_p (basetype_path, decl, true))
diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor25.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor25.C
new file mode 100644
index 0000000..fcb6e84
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/inh-ctor25.C
@@ -0,0 +1,20 @@
+// PR c++/79401
+// { dg-do compile { target c++11 } }
+
+class B
+{
+protected:
+  B (int, int);
+};
+class C : public B
+{
+protected:
+  using B::B;
+};
+class A : public C
+{
+  A (char *);
+};
+A::A (char *) : C (0, 0)
+{
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-10 18:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10 18:24 C++ PATCH for c++/79401 (protected inherited constructor) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).