https://gcc.gnu.org/g:1f4407968cafb1db79339973732f1ff8d7b0918a
commit r17-6189-g1f4407968cafb1db79339973732f1ff8d7b0918a Author: Jason Merrill <[email protected]> Date: Tue Nov 10 22:00:23 2026 -0500 c++: fix create_implicit_typedef calls My contracts-in-libstdc++ experiment had trouble with <meta> because the forward-declaration of source_location didn't have TREE_PUBLIC set. And let's also adjust the C++98 bad_alloc decl for consistency. gcc/cp/ChangeLog: * contracts.cc (lookup_std_type): Set TREE_PUBLIC. (lookup_std_contracts_type): Likewise. * decl.cc (cxx_init_operator_new_delete_decls): Likewise. Diff: --- gcc/cp/contracts.cc | 2 ++ gcc/cp/decl.cc | 1 + 2 files changed, 3 insertions(+) diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc index cd5f0bdbb16a..fe2cd3a5d254 100644 --- a/gcc/cp/contracts.cc +++ b/gcc/cp/contracts.cc @@ -365,6 +365,7 @@ lookup_std_type (tree name_id) create_implicit_typedef (name_id, res_type); DECL_SOURCE_LOCATION (TYPE_NAME (res_type)) = BUILTINS_LOCATION; DECL_CONTEXT (TYPE_NAME (res_type)) = current_namespace; + TREE_PUBLIC (TYPE_NAME (res_type)) = true; pushdecl_namespace_level (TYPE_NAME (res_type), /*hidden*/true); pop_nested_namespace (std_node); } @@ -2441,6 +2442,7 @@ lookup_std_contracts_type (tree name_id) create_implicit_typedef (name_id, res_type); DECL_SOURCE_LOCATION (TYPE_NAME (res_type)) = BUILTINS_LOCATION; DECL_CONTEXT (TYPE_NAME (res_type)) = current_namespace; + TREE_PUBLIC (TYPE_NAME (res_type)) = true; pushdecl_namespace_level (TYPE_NAME (res_type), /*hidden*/true); pop_namespace (); pop_nested_namespace (std_node); diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index d45730a13f6b..75990e412197 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -5541,6 +5541,7 @@ cxx_init_operator_new_delete_decls (void) bad_alloc_decl = create_implicit_typedef (bad_alloc_id, bad_alloc_type_node); DECL_CONTEXT (bad_alloc_decl) = current_namespace; + TREE_PUBLIC (bad_alloc_decl) = true; pop_nested_namespace (std_node); new_eh_spec
