OSDN Git Service

* gimplify.c (gimplify_decl_expr): For a TYPE_DECL, also gimplify the
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 May 2012 15:00:11 +0000 (15:00 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 May 2012 15:00:11 +0000 (15:00 +0000)
DECL_ORIGINAL_TYPE if it is present.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@187370 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/lto11.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/lto11.ads [new file with mode: 0644]

index 0f9e071..03179f4 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-10  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gimplify.c (gimplify_decl_expr): For a TYPE_DECL, also gimplify the
+       DECL_ORIGINAL_TYPE if it is present.
+
 2012-05-09  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport from 2012-05-12 mainline r187342.
 2012-05-09  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport from 2012-05-12 mainline r187342.
index 07eb8fd..9249e42 100644 (file)
@@ -1425,6 +1425,13 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
       && !TYPE_SIZES_GIMPLIFIED (TREE_TYPE (decl)))
     gimplify_type_sizes (TREE_TYPE (decl), seq_p);
 
       && !TYPE_SIZES_GIMPLIFIED (TREE_TYPE (decl)))
     gimplify_type_sizes (TREE_TYPE (decl), seq_p);
 
+  /* ??? DECL_ORIGINAL_TYPE is streamed for LTO so it needs to be gimplified
+     in case its size expressions contain problematic nodes like CALL_EXPR.  */
+  if (TREE_CODE (decl) == TYPE_DECL
+      && DECL_ORIGINAL_TYPE (decl)
+      && !TYPE_SIZES_GIMPLIFIED (DECL_ORIGINAL_TYPE (decl)))
+    gimplify_type_sizes (DECL_ORIGINAL_TYPE (decl), seq_p);
+
   if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl))
     {
       tree init = DECL_INITIAL (decl);
   if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl))
     {
       tree init = DECL_INITIAL (decl);
index c27ed90..3892db5 100644 (file)
@@ -1,3 +1,7 @@
+2012-05-10  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/lto11.ad[sb]: New test.
+
 2012-05-08  Hans-Peter Nilsson  <hp@axis.com>
 
        PR target/53272
 2012-05-08  Hans-Peter Nilsson  <hp@axis.com>
 
        PR target/53272
diff --git a/gcc/testsuite/gnat.dg/lto11.adb b/gcc/testsuite/gnat.dg/lto11.adb
new file mode 100644 (file)
index 0000000..ad0b8db
--- /dev/null
@@ -0,0 +1,20 @@
+-- { dg-do compile }
+-- { dg-options "-flto" { target lto } }
+
+with Ada.Streams; use Ada.Streams;
+
+package body Lto11 is
+
+   procedure Write
+     (S : not null access Root_Stream_Type'Class;
+      V : Vector)
+   is
+      subtype M_SEA is Stream_Element_Array (1 .. V'Size / Stream_Element'Size);
+      Bytes : M_SEA;
+      for Bytes'Address use V'Address;
+      pragma Import (Ada, Bytes);
+   begin
+      Ada.Streams.Write (S.all, Bytes);
+   end;
+
+end Lto11;
diff --git a/gcc/testsuite/gnat.dg/lto11.ads b/gcc/testsuite/gnat.dg/lto11.ads
new file mode 100644 (file)
index 0000000..386d5ac
--- /dev/null
@@ -0,0 +1,9 @@
+with Ada.Streams; use Ada.Streams;
+
+package Lto11 is
+
+   type Vector is array (Positive range <>) of Float;
+
+   procedure Write (S : not null access Root_Stream_Type'Class; V : Vector);
+
+end Lto11;