https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98231
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This seems to work...
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -9279,4 +9279,14 @@ push_operator_bindings ()
}
}
+/* Wrapper around push_local_binding to push the bindings for
+ a non-member USING_DECL that were found during template parsing. */
+
+void
+push_using_decl_bindings (tree decl)
+{
+ push_local_binding (DECL_NAME (decl), USING_DECL_DECLS (decl),
+ /*using*/true);
+}
+
#include "gt-cp-name-lookup.h"
diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
index 7172079b274..bac3fa71fc9 100644
--- a/gcc/cp/name-lookup.h
+++ b/gcc/cp/name-lookup.h
@@ -478,6 +478,7 @@ extern void push_to_top_level (void);
extern void pop_from_top_level (void);
extern void maybe_save_operator_binding (tree);
extern void push_operator_bindings (void);
+extern void push_using_decl_bindings (tree);
extern void discard_operator_bindings (tree);
/* Lower level interface for modules. */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 100c35f053c..c27ef6d9fe0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18133,6 +18133,9 @@ tsubst_expr (tree t, tree args, tsubst_flags_t
complain, tree in_decl,
tree scope = USING_DECL_SCOPE (decl);
gcc_checking_assert (scope
== tsubst (scope, args, complain, in_decl));
+ /* We still need to push the bindings so that we can look up
+ this name later. */
+ push_using_decl_bindings (decl);
}
else if (is_capture_proxy (decl)
&& !DECL_TEMPLATE_INSTANTIATION (current_function_decl))