push_nested_class (DECL_FRIEND_CONTEXT (t));
else if (DECL_CLASS_SCOPE_P (t))
push_nested_class (DECL_CONTEXT (t));
+ else if (deduction_guide_p (t) && DECL_ARTIFICIAL (t))
+ /* An artificial deduction guide should have the same access as
+ the constructor. */
+ push_nested_class (TREE_TYPE (TREE_TYPE (t)));
else
push_to_top_level ();
if (TREE_CODE (t) == FUNCTION_DECL)
current_function_decl = saved_access_scope->pop();
- if (DECL_FRIEND_CONTEXT (t) || DECL_CLASS_SCOPE_P (t))
+ if (DECL_FRIEND_CONTEXT (t)
+ || DECL_CLASS_SCOPE_P (t)
+ || (deduction_guide_p (t) && DECL_ARTIFICIAL (t)))
pop_nested_class ();
else
pop_from_top_level ();
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<class>
+struct Cont;
+
+template<class T>
+class Base
+{
+ using type = T;
+ friend Cont<T>;
+};
+
+template<class T>
+struct Cont
+{
+ using argument_type = typename Base<T>::type;
+ Cont(T, argument_type);
+};
+
+Cont c(1, 1);
--- /dev/null
+// PR c++/101174
+// { dg-do compile { target c++17 } }
+
+struct S { using type = int; };
+
+template<class T = int, class U = S>
+struct multiset {
+ using type = typename U::type;
+ multiset(T);
+ multiset(U);
+};
+
+template<class T>
+multiset(T) -> multiset<T>;
+
+multiset c(42);
decltype(std::multiset{{1, 2, 3}, std::less<int>{}, {}}),
std::multiset<int>>);
-/* FIXME: GCC 12 rejects this due to PR c++/101174
static_assert(std::is_same_v<
decltype(std::multiset{{1, 2, 3}, std::less<int>{}}),
std::multiset<int>>);
-*/
static_assert(std::is_same_v<
decltype(std::multiset{{1, 2, 3}, SimpleAllocator<int>{}}),
std::less<int>{}, {}}),
std::set<int>>);
-/* FIXME: GCC 12 rejects this due to PR c++/101174
static_assert(std::is_same_v<
decltype(std::set{{1, 2, 3},
std::less<int>{}}),
std::set<int>>);
-*/
static_assert(std::is_same_v<
decltype(std::set{{1, 2, 3},