https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126653
--- Comment #3 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:cb0b42290642c021cab5f66075a38b15d5f2772d commit r17-5519-gcb0b42290642c021cab5f66075a38b15d5f2772d Author: Marek Polacek <[email protected]> Date: Thu Sep 10 17:17:06 2026 -0400 c++/reflection: spliced namespace in using directive [PR126653] Now that r17-4860, r17-4232, and r17-4789 are all in, I can finally fix the PR that prompted all of the above. The problem here is that we are not detecting any of: [namespace.udir]/1: The splice-specifier (if any) shall designate a namespace that is not the global namespace. The nested-name-specifier, namespace-name, and splice-specifier shall not be dependent. Do so, then. And likewise for [namespace.alias]/2. Moreover, using namespace [: ^^:: :]::N; should work but currently doesn't. The problem is that when global_namespace is created with void_type_node, void_type_node is still a NULL_TREE; it only becomes a thing after c_common_nodes_and_builtins. And since global_namespace's type is null, it is wrongly considered dependent, and so the using above does not work as expected. Since this is true for not just :: but also for std::, I've adjusted type_dependent_expression_p instead. PR c++/126653 gcc/cp/ChangeLog: * cp-tree.h (check_namespace_splice): Declare. * parser.cc (cp_parser_namespace_alias_definition): Call check_namespace_splice. (cp_parser_using_directive): Likewise. Give an error if the nested-name-specifier, namespace-name, or splice-specifier is dependent. * pt.cc (type_dependent_expression_p): Return false for NAMESPACE_DECL. * reflect.cc (check_namespace_splice): New. gcc/testsuite/ChangeLog: * g++.dg/reflect/ns10.C: New test. Reviewed-by: Jason Merrill <[email protected]>
