]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* gcc-interface/decl.c (gnat_to_gnu_param): Do not strip the padding
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 8 Feb 2015 10:12:38 +0000 (10:12 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 8 Feb 2015 10:12:38 +0000 (10:12 +0000)
if the parameter either is passed by reference or if the alignment
would be lowered.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@220514 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 59c6c3886eb331d17946c10c00612b0fcd7fb3ca..874779e44ea8bc495f2009a32abc8b791217f8ea 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-08  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_param): Do not strip the padding
+       if the parameter either is passed by reference or if the alignment
+       would be lowered.
+
 2015-02-08  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/decl.c (is_cplusplus_method): Use Is_Primitive flag to
index c7d64aab4497f2609f1cc4d9b4327f2f44dc8dc0..94043b6a397be2159a42b87ca51f1d1b9c5c02b3 100644 (file)
@@ -5659,15 +5659,17 @@ gnat_to_gnu_param (Entity_Id gnat_param, Mechanism_Type mech,
     }
 
   /* If this is either a foreign function or if the underlying type won't
-     be passed by reference, strip off possible padding type.  */
+     be passed by reference and is as aligned as the original type, strip
+     off possible padding type.  */
   if (TYPE_IS_PADDING_P (gnu_param_type))
     {
       tree unpadded_type = TREE_TYPE (TYPE_FIELDS (gnu_param_type));
 
-      if (mech == By_Reference
-         || foreign
+      if (foreign
          || (!must_pass_by_ref (unpadded_type)
-             && (mech == By_Copy || !default_pass_by_ref (unpadded_type))))
+             && mech != By_Reference
+             && (mech == By_Copy || !default_pass_by_ref (unpadded_type))
+             && TYPE_ALIGN (unpadded_type) >= TYPE_ALIGN (gnu_param_type)))
        gnu_param_type = unpadded_type;
     }
 
index dbe52cf0fd6f5c6388339a77fbcecf3dab84bc48..878338960ceb2f31db4e419d812ecc26855b0dbc 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-08  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/addr7.ad[sb]: New test.
+       * gnat.dg/addr8.ad[sb]: Likewise.
+
 2015-02-06  David Malcolm  <dmalcolm@redhat.com>
 
        PR jit/64752
diff --git a/gcc/testsuite/gnat.dg/addr7.adb b/gcc/testsuite/gnat.dg/addr7.adb
new file mode 100644 (file)
index 0000000..982b50e
--- /dev/null
@@ -0,0 +1,12 @@
+-- { dg-do compile }
+
+package body Addr7 is
+
+   procedure Proc (B: aliased Bytes) is
+      O: Integer;
+      for O'Address use B'Address;
+   begin
+      null;
+   end;
+
+end Addr7;
diff --git a/gcc/testsuite/gnat.dg/addr7.ads b/gcc/testsuite/gnat.dg/addr7.ads
new file mode 100644 (file)
index 0000000..19fbb0e
--- /dev/null
@@ -0,0 +1,8 @@
+package Addr7 is
+
+   type Bytes is array (1 .. 4) of Character;
+   for Bytes'Alignment use 4;
+
+   procedure Proc (B: aliased Bytes);
+
+end Addr7;
diff --git a/gcc/testsuite/gnat.dg/addr8.adb b/gcc/testsuite/gnat.dg/addr8.adb
new file mode 100644 (file)
index 0000000..9105c22
--- /dev/null
@@ -0,0 +1,12 @@
+-- { dg-do compile }
+
+package body Addr8 is
+
+   procedure Proc (B: Bytes) is
+      O: Integer;
+      for O'Address use B'Address;
+   begin
+      null;
+   end;
+
+end Addr8;
diff --git a/gcc/testsuite/gnat.dg/addr8.ads b/gcc/testsuite/gnat.dg/addr8.ads
new file mode 100644 (file)
index 0000000..ab648e1
--- /dev/null
@@ -0,0 +1,8 @@
+package Addr8 is
+
+   type Bytes is array (1 .. 4) of Character;
+   for Bytes'Alignment use 4;
+
+   procedure Proc (B: Bytes);
+
+end Addr8;