PR c++/79401 - protected inherited constructor
authorJason Merrill <jason@redhat.com>
Fri, 10 Feb 2017 18:01:27 +0000 (13:01 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 10 Feb 2017 18:01:27 +0000 (13:01 -0500)
* call.c (enforce_access): For inheriting constructor, find a base
binfo in the path we already have.

From-SVN: r245339

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/inh-ctor25.C [new file with mode: 0644]

index 5ea0c930a096305bfa378c84a10125aac412722f..688a3bce86ee1adbd0df5ae1cd0b9923a171c591 100644 (file)
@@ -1,3 +1,9 @@
+2017-02-10  Jason Merrill  <jason@redhat.com>
+
+       PR c++/79401 - protected inherited constructor
+       * call.c (enforce_access): For inheriting constructor, find a base
+       binfo in the path we already have.
+
 2017-02-10  Marek Polacek  <polacek@redhat.com>
 
        PR c++/79435
index 6533214799d1bf40d68cf8b3bd3d104ebd2a4b75..718438cff1b85a2a2f60aa98a25e2cbbe40cefec 100644 (file)
@@ -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 (file)
index 0000000..fcb6e84
--- /dev/null
@@ -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)
+{
+}