]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (gnat_to_gnu_entity): For an object at global level with unconstrained nominal...
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 18 May 2012 20:33:49 +0000 (20:33 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 18 May 2012 20:33:49 +0000 (20:33 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: For an object at
global level with unconstrained nominal subtype and a non-fixed size,
make a variable for the size.

From-SVN: r187666

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

index b67d659a127653b1bff9a193986442f74e2d10ee..832317b7ad41999290973d9cb644b118dc6c1e17 100644 (file)
@@ -1,3 +1,9 @@
+2012-05-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: For an object at
+       global level with unconstrained nominal subtype and a non-fixed size,
+       make a variable for the size.
+
 2012-05-15  Andris Pavenis  <andris.pavenis@iki.fi>
 
        PR ada/52494
index 97ade5e6159028e987cb90f6f966182af76dc5dd..bb3626946fefd9ca2443a1259ed4561f384af862 100644 (file)
@@ -760,6 +760,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
                gnu_size = max_size (TYPE_SIZE (gnu_type), true);
                mutable_p = true;
              }
+
+           /* If we are at global level and the size isn't constant, call
+              elaborate_expression_1 to make a variable for it rather than
+              calculating it each time.  */
+           if (global_bindings_p () && !TREE_CONSTANT (gnu_size))
+             gnu_size = elaborate_expression_1 (gnu_size, gnat_entity,
+                                                get_identifier ("SIZE"),
+                                                definition, false);
          }
 
        /* If the size is zero byte, make it one byte since some linkers have
index 87941bd7aa58752df4f3dcfab80e19954d39ccc1..697090fb1510800f441974ced6d208780752bbac 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/specs/lto12.ads: New test.
+       * gnat.dg/specs/lto12_pkg.ads: New helper.
+
 2012-05-18  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/53346
diff --git a/gcc/testsuite/gnat.dg/specs/lto12.ads b/gcc/testsuite/gnat.dg/specs/lto12.ads
new file mode 100644 (file)
index 0000000..3914e0f
--- /dev/null
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+-- { dg-options "-flto" { target lto } }
+
+with Lto12_Pkg; use Lto12_Pkg;
+
+package Lto12 is
+
+  C : constant R := F;
+
+end Lto12;
diff --git a/gcc/testsuite/gnat.dg/specs/lto12_pkg.ads b/gcc/testsuite/gnat.dg/specs/lto12_pkg.ads
new file mode 100644 (file)
index 0000000..02ee491
--- /dev/null
@@ -0,0 +1,14 @@
+-- { dg-excess-errors "cannot generate code" }
+
+package Lto12_Pkg is
+
+  type R (Kind  : Boolean := False) is record
+    case Kind is
+      when True => I : Integer;
+      when others => null;
+    end case;
+  end record;
+
+  function F return R;
+
+end Lto12_Pkg;