aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.cc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2025-01-31 12:41:19 +0100
committerEric Botcazou <ebotcazou@adacore.com>2025-01-31 12:47:46 +0100
commit3b49727014f29d46a605ffff228d137e5e582df3 (patch)
tree50a6d5c5e00c4743d92bd3a388b1a6ca1111635a /gcc/ada/gcc-interface/utils.cc
parent9fc0683082067801e3790f7cfffedbf5441e0f82 (diff)
downloadgcc-3b49727014f29d46a605ffff228d137e5e582df3.zip
gcc-3b49727014f29d46a605ffff228d137e5e582df3.tar.gz
gcc-3b49727014f29d46a605ffff228d137e5e582df3.tar.bz2
Fix wrong elaboration for allocator at library level of dynamic library
The problem was preexisting for class-wide allocators, but now occurs for allocators of controlled types too, because of the recent overhaul of the finalization machinery. gcc/ada/ * gcc-interface/utils.cc (gnat_pushdecl): Clear TREE_PUBLIC on functions really nested in another function.
Diffstat (limited to 'gcc/ada/gcc-interface/utils.cc')
-rw-r--r--gcc/ada/gcc-interface/utils.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index 5a90a1b..1448716 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -882,16 +882,20 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
if (!deferred_decl_context && !context)
context = get_global_context ();
- /* Functions imported in another function are not really nested.
- For really nested functions mark them initially as needing
- a static chain for uses of that flag before unnesting;
- lower_nested_functions will then recompute it. */
+ /* Mark functions really nested in another function, that is to say defined
+ there as opposed to imported from elsewhere, as initially needing a static
+ chain for the sake of uniformity (lower_nested_functions will recompute it
+ exacly later) and as private to the translation unit (the static chain may
+ be clobbered by calling conventions used across translation units). */
if (TREE_CODE (decl) == FUNCTION_DECL
- && !TREE_PUBLIC (decl)
+ && !DECL_EXTERNAL (decl)
&& context
&& (TREE_CODE (context) == FUNCTION_DECL
|| decl_function_context (context)))
- DECL_STATIC_CHAIN (decl) = 1;
+ {
+ DECL_STATIC_CHAIN (decl) = 1;
+ TREE_PUBLIC (decl) = 0;
+ }
if (!deferred_decl_context)
DECL_CONTEXT (decl) = context;