aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorOlivier Hainque <hainque@adacore.com>2008-07-17 14:18:27 +0000
committerOlivier Hainque <hainque@gcc.gnu.org>2008-07-17 14:18:27 +0000
commita7a46bb2d96c538337c19f5ba9bb55fb7b34c726 (patch)
tree3b74d3ff953a20ee785835248912fbefebafef7c /gcc/ada
parent711b299844b8eb77451d96a360f4525fc005279e (diff)
downloadgcc-a7a46bb2d96c538337c19f5ba9bb55fb7b34c726.zip
gcc-a7a46bb2d96c538337c19f5ba9bb55fb7b34c726.tar.gz
gcc-a7a46bb2d96c538337c19f5ba9bb55fb7b34c726.tar.bz2
utils.c (create_var_decl_1): Relax expectations on the PUBLIC_FLAG argument...
ada/ * utils.c (create_var_decl_1): Relax expectations on the PUBLIC_FLAG argument, to apply to references in addition to definitions. Prevent setting TREE_STATIC on externals. (gnat_pushdecl): Always clear DECL_CONTEXT on public externals. testsuite/ * gnat.dg/tree_static_def.ad[bs]: Support for ... * gnat.dg/tree_static_use.adb: New test. * gnat.dg/decl_ctx_def.ads: Support for ... * gnat.dg/decl_ctx_use.ad[bs]: New test. From-SVN: r137923
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/utils.c16
2 files changed, 16 insertions, 7 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 92f6d7b..696e9d1 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2008-07-17 Olivier Hainque <hainque@adacore.com>
+
+ * utils.c (create_var_decl_1): Relax expectations on the PUBLIC_FLAG
+ argument, to apply to references in addition to definitions. Prevent
+ setting TREE_STATIC on externals.
+ (gnat_pushdecl): Always clear DECL_CONTEXT on public externals.
+
2008-07-14 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
PR documentation/15479
diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c
index 92e8348..2782559 100644
--- a/gcc/ada/utils.c
+++ b/gcc/ada/utils.c
@@ -418,9 +418,11 @@ gnat_poplevel ()
void
gnat_pushdecl (tree decl, Node_Id gnat_node)
{
- /* If at top level, there is no context. But PARM_DECLs always go in the
- level of its function. */
- if (global_bindings_p () && TREE_CODE (decl) != PARM_DECL)
+ /* If this decl is public external or at toplevel, there is no context.
+ But PARM_DECLs always go in the level of its function. */
+ if (TREE_CODE (decl) != PARM_DECL
+ && ((DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
+ || global_bindings_p ()))
DECL_CONTEXT (decl) = 0;
else
{
@@ -1471,9 +1473,9 @@ create_type_decl (tree type_name, tree type, struct attrib *attr_list,
CONST_FLAG is true if this variable is constant, in which case we might
return a CONST_DECL node unless CONST_DECL_ALLOWED_P is false.
- PUBLIC_FLAG is true if this definition is to be made visible outside of
- the current compilation unit. This flag should be set when processing the
- variable definitions in a package specification.
+ PUBLIC_FLAG is true if this is for a reference to a public entity or for a
+ definition to be made visible outside of the current compilation unit, for
+ instance variable definitions in a package specification.
EXTERN_FLAG is nonzero when processing an external variable declaration (as
opposed to a definition: no storage is to be allocated for the variable).
@@ -1549,7 +1551,7 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init,
variable if and only if it's not external. If we are not at the top level
we allocate automatic storage unless requested not to. */
TREE_STATIC (var_decl)
- = public_flag || (global_bindings_p () ? !extern_flag : static_flag);
+ = !extern_flag && (public_flag || static_flag || global_bindings_p ());
if (asm_name && VAR_OR_FUNCTION_DECL_P (var_decl))
SET_DECL_ASSEMBLER_NAME (var_decl, asm_name);