]> gcc.gnu.org Git - gcc.git/commitdiff
utils2.c (gnat_protect_expr): Make a SAVE_EXPR only for fat pointer or scalar types.
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 17 Feb 2016 09:08:09 +0000 (09:08 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 17 Feb 2016 09:08:09 +0000 (09:08 +0000)
* gcc-interface/utils2.c (gnat_protect_expr): Make a SAVE_EXPR only
for fat pointer or scalar types.

From-SVN: r233484

gcc/ada/ChangeLog
gcc/ada/gcc-interface/utils2.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/discr46.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/discr46.ads [new file with mode: 0644]

index b2e9726a05f8c32ea93025b074cb8c47c27bf059..60ff796610222dd7f86c87c759d8a60b7c011ea4 100644 (file)
@@ -1,3 +1,8 @@
+2016-02-17  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/utils2.c (gnat_protect_expr): Make a SAVE_EXPR only
+       for fat pointer or scalar types.
+
 2016-02-16  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/gigi.h (maybe_debug_type): New inline function.
index ba4a5dca3e89c04321144fc8b05f63fea5f27bab..44a05fb012d4fcc95d0a3881e40872f664f010a5 100644 (file)
@@ -2559,12 +2559,11 @@ gnat_protect_expr (tree exp)
     return build3 (code, type, gnat_protect_expr (TREE_OPERAND (exp, 0)),
                   TREE_OPERAND (exp, 1), TREE_OPERAND (exp, 2));
 
-  /* If this is a fat pointer or something that can be placed in a register,
-     just make a SAVE_EXPR.  Likewise for a CALL_EXPR as large objects are
-     returned via invisible reference in most ABIs so the temporary will
-     directly be filled by the callee.  */
+  /* If this is a fat pointer or a scalar, just make a SAVE_EXPR.  Likewise
+     for a CALL_EXPR as large objects are returned via invisible reference
+     in most ABIs so the temporary will directly be filled by the callee.  */
   if (TYPE_IS_FAT_POINTER_P (type)
-      || TYPE_MODE (type) != BLKmode
+      || !AGGREGATE_TYPE_P (type)
       || code == CALL_EXPR)
     return save_expr (exp);
 
index df83072ae35050f85b488b1d5d4aca59be70605c..397b40f4049d22c9ddb748eb400b1032cac62cc7 100644 (file)
@@ -1,3 +1,7 @@
+2016-02-17  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/discr46.ad[sb]: New test.
+
 2016-02-16  Kelvin Nilsen  <kelvin@gcc.gnu.org>
 
        PR Target/48344
diff --git a/gcc/testsuite/gnat.dg/discr46.adb b/gcc/testsuite/gnat.dg/discr46.adb
new file mode 100644 (file)
index 0000000..84ac91d
--- /dev/null
@@ -0,0 +1,14 @@
+-- { dg-do compile }
+
+package body Discr46 is
+
+   function F (Id : Enum) return Integer is
+      Node : Integer := 0;
+   begin
+      if A (Id).R.D = True then
+         Node := A (Id).R.T;
+      end if;
+      return Node;
+   end; 
+
+end Discr46;
diff --git a/gcc/testsuite/gnat.dg/discr46.ads b/gcc/testsuite/gnat.dg/discr46.ads
new file mode 100644 (file)
index 0000000..18b0de1
--- /dev/null
@@ -0,0 +1,24 @@
+package Discr46 is
+
+   type Enum is (One, Two, Three);
+   for Enum use (One => 1, Two => 2, Three => 3);
+
+   type Rec1 (D : Boolean := False) is record
+      case D is
+         when False => null;
+         when True => T : Integer;
+      end case;
+   end record;
+
+   type Rec2 is record
+      R : Rec1;
+      C : Character;
+   end record;
+
+   type Arr is array (Enum) of Rec2;
+
+   A : Arr; 
+
+   function F (Id : Enum) return Integer;  
+
+end Discr46;
This page took 0.073983 seconds and 5 git commands to generate.