aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2012-06-11 08:34:44 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2012-06-11 08:34:44 +0000
commit9083aacd090fc35f85659bdaa812384779ef73e2 (patch)
treeee4cd62633fa310c78b4c77fb3f1bdca4a4fae92 /gcc
parent9cbad0a3624eb087ff3c05457aa41d5c595f5a85 (diff)
downloadgcc-9083aacd090fc35f85659bdaa812384779ef73e2.zip
gcc-9083aacd090fc35f85659bdaa812384779ef73e2.tar.gz
gcc-9083aacd090fc35f85659bdaa812384779ef73e2.tar.bz2
decl.c (gnat_to_gnu_entity): Do not specifically deal with external constants wrt force_global here...
* gcc-interface/decl.c (gnat_to_gnu_entity): Do not specifically deal with external constants wrt force_global here... <E_Constant>: ...but here instead. * gcc-interface/utils.c (gnat_pushdecl): Do not put external DECLs onto the list of global DECLs. From-SVN: r188379
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog8
-rw-r--r--gcc/ada/gcc-interface/decl.c7
-rw-r--r--gcc/ada/gcc-interface/utils.c8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gnat.dg/constant4.adb12
-rw-r--r--gcc/testsuite/gnat.dg/constant4_pkg.ads15
6 files changed, 48 insertions, 7 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index dcd9473..031d661 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,13 @@
2012-06-11 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/decl.c (gnat_to_gnu_entity): Do not specifically deal
+ with external constants wrt force_global here...
+ <E_Constant>: ...but here instead.
+ * gcc-interface/utils.c (gnat_pushdecl): Do not put external DECLs onto
+ the list of global DECLs.
+
+2012-06-11 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/decl.c (gnat_to_gnu_entity): Translate the Esize on
entry only for elementary types and abort if it is too large.
<E_Record_Type>: Make sure the Esize is known before using it.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 1c7f337..ce2f94a 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -348,12 +348,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
another compilation unit) public entities, show we are at global level
for the purpose of computing scopes. Don't do this for components or
discriminants since the relevant test is whether or not the record is
- being defined. Don't do this for constants either as we'll look into
- their defining expression in the local context. */
+ being defined. */
if (!definition
&& kind != E_Component
&& kind != E_Discriminant
- && kind != E_Constant
&& Is_Public (gnat_entity)
&& !Is_Statically_Allocated (gnat_entity))
force_global++, this_global = true;
@@ -424,6 +422,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
!= N_Allocator)
{
bool went_into_elab_proc = false;
+ int save_force_global = force_global;
/* The expression may contain N_Expression_With_Actions nodes and
thus object declarations from other units. In this case, even
@@ -436,11 +435,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
current_function_decl = get_elaboration_procedure ();
went_into_elab_proc = true;
}
+ force_global = 0;
gnat_pushlevel ();
gnu_expr = gnat_to_gnu (Expression (Declaration_Node (gnat_entity)));
gnat_zaplevel ();
+ force_global = save_force_global;
if (went_into_elab_proc)
current_function_decl = NULL_TREE;
}
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 5800308..db909d9 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -572,14 +572,14 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
if (!(TREE_CODE (decl) == TYPE_DECL
&& TREE_CODE (TREE_TYPE (decl)) == UNCONSTRAINED_ARRAY_TYPE))
{
- if (global_bindings_p ())
+ if (DECL_EXTERNAL (decl))
{
- VEC_safe_push (tree, gc, global_decls, decl);
-
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
VEC_safe_push (tree, gc, builtin_decls, decl);
}
- else if (!DECL_EXTERNAL (decl))
+ else if (global_bindings_p ())
+ VEC_safe_push (tree, gc, global_decls, decl);
+ else
{
DECL_CHAIN (decl) = BLOCK_VARS (current_binding_level->block);
BLOCK_VARS (current_binding_level->block) = decl;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 60c8e28..b8c9c7b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-11 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/constant4.adb: New test.
+ * gnat.dg/constant4_pkg.ads: New helper.
+
2012-06-08 Janus Weil <janus@gcc.gnu.org>
PR fortran/52552
diff --git a/gcc/testsuite/gnat.dg/constant4.adb b/gcc/testsuite/gnat.dg/constant4.adb
new file mode 100644
index 0000000..826823a
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/constant4.adb
@@ -0,0 +1,12 @@
+-- { dg-do link }
+-- { dg-options "-gnat12" }
+
+with Constant4_Pkg; use Constant4_Pkg;
+
+procedure Constant4 is
+ Sum : Counter := 0;
+begin
+ for Count of Steals loop
+ Sum := Sum + Count;
+ end loop;
+end;
diff --git a/gcc/testsuite/gnat.dg/constant4_pkg.ads b/gcc/testsuite/gnat.dg/constant4_pkg.ads
new file mode 100644
index 0000000..f0c6f8f
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/constant4_pkg.ads
@@ -0,0 +1,15 @@
+with Ada.Command_Line; use Ada.Command_Line;
+with System.Multiprocessors; use System.Multiprocessors;
+
+package Constant4_Pkg is
+
+ Max_CPUs : constant CPU := (if Argument_Count < 2 then Number_Of_CPUs
+ else CPU'Value (Argument (2)));
+
+ subtype Worker_Id is CPU range 1 .. Max_CPUs;
+
+ type Counter is range 0 .. 10**18;
+
+ Steals : array (Worker_Id) of Counter := (others => 0);
+
+end Constant4_Pkg;