else
push_to_top_level ();
@@ -255,7 +259,9 @@ pop_access_scope (tree t)
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 ();
@@ -28804,9 +28810,6 @@ 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;
}
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction-access3.C
b/gcc/testsuite/g++.dg/cpp1z/class-deduction-access3.C
new file mode 100644
index 00000000000..44b4b5c455f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction-access3.C
@@ -0,0 +1,22 @@
+// { dg-do compile { target c++17 } }
+
+template<typename T>
+struct Cont;
+
+template<typename T>
+struct Base
+{
+private:
+ using type = T;
+ friend Cont<T>;
+};
+
+template<typename T>
+struct Cont
+{
+ using argument_type = typename Base<T>::type;
+
+ Cont(T, argument_type) { }
+};
+
+Cont c(1, 1);
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction91.C
b/gcc/testsuite/g++.dg/cpp1z/class-deduction91.C
new file mode 100644
index 00000000000..f474c8e35ec
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction91.C
@@ -0,0 +1,16 @@
+// 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);
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/cons/deduction.cc
b/libstdc++-v3/testsuite/23_containers/multiset/cons/deduction.cc
index a4ccc6fa467..8b7a16042a4 100644
--- a/libstdc++-v3/testsuite/23_containers/multiset/cons/deduction.cc
+++ b/libstdc++-v3/testsuite/23_containers/multiset/cons/deduction.cc
@@ -19,11 +19,9 @@ static_assert(std::is_same_v<
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>{}}),
diff --git a/libstdc++-v3/testsuite/23_containers/set/cons/deduction.cc
b/libstdc++-v3/testsuite/23_containers/set/cons/deduction.cc
index 0ae4c2a5c5f..14f36b7c05d 100644
--- a/libstdc++-v3/testsuite/23_containers/set/cons/deduction.cc
+++ b/libstdc++-v3/testsuite/23_containers/set/cons/deduction.cc
@@ -20,12 +20,10 @@ static_assert(std::is_same_v<
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},