Jonathan raised this issue with CWG, and there seems to be general agreement
that a deduction guide generated from a constructor should have access to
the same names that the constructor has access to. That seems to be as easy
as setting DECL_CONTEXT.
gcc/cp/ChangeLog:
* pt.c (build_deduction_guide): Treat the implicit deduction guide
as a member of the class.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/class-deduction-access1.C: New test.
* g++.dg/cpp1z/class-deduction-access2.C: New test.
DECL_ABSTRACT_ORIGIN (ded_tmpl) = fn_tmpl;
if (ci)
set_constraints (ded_tmpl, ci);
+ /* The artificial deduction guide should have same access as the
+ constructor. */
+ DECL_CONTEXT (ded_fn) = type;
return ded_tmpl;
}
--- /dev/null
+// { dg-do compile { target c++17 } }
+
+template<typename T>
+struct Base
+{
+protected:
+ using type = T;
+};
+
+template<typename T>
+struct Cont : Base<T>
+{
+ using argument_type = typename Base<T>::type;
+
+ Cont(T, argument_type) { }
+};
+
+Cont c(1, 1);
--- /dev/null
+// { dg-do compile { target c++17 } }
+
+struct B {
+protected:
+ struct type {};
+};
+template<typename T> struct D : B {
+ D(T, typename T::type);
+};
+D c = {B(), {}};