https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127344

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <[email protected]>:

https://gcc.gnu.org/g:e65b3092ce078418632186b7d67c3e443f6657fd

commit r17-4860-ge65b3092ce078418632186b7d67c3e443f6657fd
Author: Marek Polacek <[email protected]>
Date:   Fri Sep 11 15:40:37 2026 -0400

    c++/reflection: ICE with ns splice scope in ns alias [PR127344]

    This fixes another problem when using namespace splice scopes,
    this time in a namespace alias like this:

      template<auto ns> void f () {
        namespace A = [:ns:];
        int i = A::N::x;
      }

    where we crash in make_typename_type or make_unbound_class_template
    because they expect a type but get a NAMESPACE_DECL built for the
    A alias with ORIGINAL_NAMESPACE being a SPLICE_EXPR.  The decl is
    coming from cp_parser_namespace_alias_definition -> do_namespace_alias.

    We want a SPLICE_SCOPE which is a type, so build one with
    make_splice_scope.

    I considered changing cp_parser_namespace_alias_definition to build
    the SPLICE_SCOPE there but that brought so many other issues that it
    wasn't worth it.

            PR c++/127344

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_lookup_name): Call make_splice_scope for
            dependent_namespace_p.  Use the result for make_typename_type
            and make_unbound_class_template.

    gcc/testsuite/ChangeLog:

            * g++.dg/reflect/ns9.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>

Reply via email to