summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2017-12-14 17:03:16 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2017-12-14 17:03:16 +0000
commit9ca42b6474e1f5b4caeaa58e36aaf993951660af (patch)
treec9c67232537cb4573931da8efbab3fe4fc445a49
parent08014e8ab9673f0625a27d1e9e374107b4dbd7c7 (diff)
downloadgcc-9ca42b6474e1f5b4caeaa58e36aaf993951660af.tar.gz
* gcc-interface/decl.c (gnat_to_gnu_field): Do not set the alignment
of the enclosing record type if it is not already set. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255645 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/decl.c3
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/alignment13.adb21
4 files changed, 32 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 3ac3bfba6e5..c87f4a22692 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2017-12-14 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/decl.c (gnat_to_gnu_field): Do not set the alignment
+ of the enclosing record type if it is not already set.
+
+2017-12-14 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/gigi.h (pad_type_has_rm_size): Declare.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Do not build
a padding type for the alignment before validating the size.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index f2da070ab0f..b014e687f6d 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -6890,7 +6890,8 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
{
const unsigned int type_align = TYPE_ALIGN (gnu_field_type);
- if (TYPE_ALIGN (gnu_record_type) < type_align)
+ if (TYPE_ALIGN (gnu_record_type)
+ && TYPE_ALIGN (gnu_record_type) < type_align)
SET_TYPE_ALIGN (gnu_record_type, type_align);
/* If the position is not a multiple of the alignment of the type,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4fac0015fd2..f87fb481899 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2017-12-14 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/alignment13.adb: New test.
+
2017-12-14 Jakub Jelinek <jakub@redhat.com>
PR lto/81406
diff --git a/gcc/testsuite/gnat.dg/alignment13.adb b/gcc/testsuite/gnat.dg/alignment13.adb
new file mode 100644
index 00000000000..dd0b25425f0
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/alignment13.adb
@@ -0,0 +1,21 @@
+-- { dg-do run }
+-- { dg-options "-gnatws" }
+
+procedure Alignment13 is
+
+ type Rec is record
+ I1 : aliased Short_Integer;
+ I2 : Integer;
+ end record;
+
+ for Rec use record
+ I1 at 0 range 0 .. 15;
+ end record;
+
+ R : Rec;
+
+begin
+ if R.I2'Bit_Position /= 32 then
+ raise Program_Error;
+ end if;
+end;