c++: Fix up access_context::current and current_namespace

On Mon, Mar 30, 2026 at 01:15:07PM +0200, Tomasz Kaminski wrote:
> > auto
> > Q::baz () -> typename [: current_namespace () == ^^Q ? ^^int : ^^:: :]
> > {
> >   return 0;
> > }
> > part also fails, there I don't know what's right but possibly it should
> > be in Q; in that case it would be a pre-existing bug already for
> > std::meta::access_context::current () too.
> >
> My reading of the standard may be wrong here.

I think you're right, but because it is a preexisting bug on
access_context, sending this as a separate patch rather than
updating the current_* patch.

2026-04-01  Jakub Jelinek  <jakub@redhat.com>

	* reflect.cc (reflect_current_scope): Use decl_namespace_list->last ()
	in preference to current_namespace.

	* g++.dg/reflect/access_context1.C: Add new tests.
	* g++.dg/reflect/current_function1.C: Likewise.
	* g++.dg/reflect/current_class1.C: Likewise.
	* g++.dg/reflect/current_class2.C: Likewise.
	* g++.dg/reflect/current_namespace1.C: Likewise.

Reviewed-by: Jason Merrill <jason@redhat.com>
6 files changed