https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126233
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
--- gcc/cp/pt.cc.jj 2026-07-13 11:53:09.907610894 +0200
+++ gcc/cp/pt.cc 2026-07-13 11:59:35.726709201 +0200
@@ -7715,6 +7715,10 @@ convert_nontype_argument (tree type, tre
return error_mark_node;
}
+ /* Handle template arguments as outside of any function for
+ __builtin_source_location () purposes. */
+ temp_override<tree> ovr (current_function_decl, NULL_TREE);
+
/* If we are in a template, EXPR may be non-dependent, but still
have a syntactic, rather than semantic, form. For example, EXPR
might be a SCOPE_REF, rather than the VAR_DECL to which the
regresses
FAIL: g++.dg/reflect/parse2.C -std=c++26 (test for excess errors)
FAIL: g++.dg/reflect/parse2.C -std=c++29 (test for excess errors)
tests though, so current_function_decl is clearly used in more than just
__builtin_source_location.