@@ -28803,6 +28803,9 @@ build_deduction_guide (tree type, tree ctor, tree outer_args, tsubst_flags_t com
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;
}
new file mode 100644
@@ -0,0 +1,18 @@
+// { 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);
new file mode 100644
@@ -0,0 +1,10 @@
+// { 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(), {}};