FUNCTION_DECL which is the desired context for access checking
is not built yet. We solve this chicken-and-egg problem by
deferring all checks until we have the FUNCTION_DECL. */
- push_deferring_access_checks (dk_deferred);
+ deferring_access_check_sentinel dacs (dk_deferred);
/* Instantiation of the function happens in the context of the function
template, not the context of the overload resolution we're doing. */
pop_from_top_level ();
if (fndecl == error_mark_node)
- {
- pop_deferring_access_checks ();
- return error_mark_node;
- }
+ return error_mark_node;
+
+ /* Substituting the type might have recursively instantiated this
+ same alias (c++/117530). */
+ if (DECL_ALIAS_TEMPLATE_P (gen_tmpl)
+ && (spec = retrieve_specialization (gen_tmpl, targ_ptr, hash)))
+ return spec;
/* The DECL_TI_TEMPLATE should always be the immediate parent
template, not the most general template. */
access_ok = false;
pop_access_scope (fndecl);
}
- pop_deferring_access_checks ();
/* If we've just instantiated the main entry point for a function,
instantiate all the alternate entry points as well. We do this
--- /dev/null
+// PR c++/117530
+// { dg-do compile { target c++20 } }
+
+template <class> struct A;
+template <class T> using B = decltype([]() -> A<T>::X { return 0; });
+template <class T> struct A {
+ typedef int X;
+ typedef B<T> U;
+};
+B<short> b;