]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (elaborate_expression_1): Add EXPR_PUBLIC_P local variable.
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 26 Oct 2011 21:05:10 +0000 (21:05 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 26 Oct 2011 21:05:10 +0000 (21:05 +0000)
* gcc-interface/decl.c (elaborate_expression_1): Add EXPR_PUBLIC_P local
variable.  Always create the elaboration variable, if any, as constant.

From-SVN: r180541

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/specs/discr1.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/discr1_pkg.ads [new file with mode: 0644]

index 53ea8c575c6327256e1cc946f0cd3e8b95b346b6..7883ad6f8d6dd97d10a4ba7419419371d4dfc546 100644 (file)
@@ -1,4 +1,9 @@
 
+2011-10-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (elaborate_expression_1): Add EXPR_PUBLIC_P local
+       variable.  Always create the elaboration variable, if any, as constant.
+
 2011-10-26  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Subtype>: Try to
index 9c7c318ced575dbdc28e063571bc6af98b5f767c..49434430ecd94ffe3be27929152f56c38f3e81d6 100644 (file)
@@ -6085,7 +6085,8 @@ static tree
 elaborate_expression_1 (tree gnu_expr, Entity_Id gnat_entity, tree gnu_name,
                        bool definition, bool need_debug)
 {
-  const bool expr_global_p = Is_Public (gnat_entity) || global_bindings_p ();
+  const bool expr_public_p = Is_Public (gnat_entity);
+  const bool expr_global_p = expr_public_p || global_bindings_p ();
   bool expr_variable_p, use_variable;
 
   /* In most cases, we won't see a naked FIELD_DECL because a discriminant
@@ -6153,11 +6154,10 @@ elaborate_expression_1 (tree gnu_expr, Entity_Id gnat_entity, tree gnu_name,
   if (use_variable || need_debug)
     {
       tree gnu_decl
-       = create_var_decl (create_concat_name (gnat_entity,
-                                              IDENTIFIER_POINTER (gnu_name)),
-                          NULL_TREE, TREE_TYPE (gnu_expr), gnu_expr,
-                          !need_debug, Is_Public (gnat_entity),
-                          !definition, expr_global_p, NULL, gnat_entity);
+       = create_var_decl_1
+         (create_concat_name (gnat_entity, IDENTIFIER_POINTER (gnu_name)),
+          NULL_TREE, TREE_TYPE (gnu_expr), gnu_expr, true, expr_public_p,
+          !definition, expr_global_p, !need_debug, NULL, gnat_entity);
 
       if (use_variable)
        return gnu_decl;
index d8380fbb6342e7d7932b2598cdfd301cccc33a13..15d3f237bd7a228889726ddb70e3b0f5f7cf36b1 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/specs/discr1.ads: New test.
+       * gnat.dg/specs/discr1_pkg.ads: New helper.
+
 2011-10-26  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/specs/unchecked_union.ads: Rename to...
diff --git a/gcc/testsuite/gnat.dg/specs/discr1.ads b/gcc/testsuite/gnat.dg/specs/discr1.ads
new file mode 100644 (file)
index 0000000..2e02076
--- /dev/null
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+-- { dg-options "-gnatct" }
+
+with Discr1_Pkg; use Discr1_Pkg;
+
+package Discr1 is
+
+  procedure Proc (V : Variable_String_Array);
+
+end Discr1;
diff --git a/gcc/testsuite/gnat.dg/specs/discr1_pkg.ads b/gcc/testsuite/gnat.dg/specs/discr1_pkg.ads
new file mode 100644 (file)
index 0000000..4bb40ad
--- /dev/null
@@ -0,0 +1,14 @@
+package Discr1_Pkg is
+
+  Maximum_Length : Natural := 80 ;
+
+  subtype String_Length is Natural range 0 .. Maximum_Length;
+
+  type Variable_String (Length : String_Length := 0) is
+    record
+      S : String (1 .. Length);
+    end record;
+
+  type Variable_String_Array is array (Natural range <>) of Variable_String;
+
+end Discr1_Pkg;