aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2016-03-27 09:57:36 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2016-03-27 09:57:36 +0000
commita1799e5ef7a4aaae3015a8ef8a5e49d91a1c3775 (patch)
tree3433f260719b88f30ce9afb1f69894d9264701d5
parent5f7f4dffdc27d4252b49605f162ddd1c7f6f69e4 (diff)
downloadgcc-a1799e5ef7a4aaae3015a8ef8a5e49d91a1c3775.zip
gcc-a1799e5ef7a4aaae3015a8ef8a5e49d91a1c3775.tar.gz
gcc-a1799e5ef7a4aaae3015a8ef8a5e49d91a1c3775.tar.bz2
decl.c (components_to_record): Add special case for single field with representation clause at offset 0.
* gcc-interface/decl.c (components_to_record): Add special case for single field with representation clause at offset 0. From-SVN: r234494
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/decl.c17
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/specs/double_record_extension3.ads22
4 files changed, 48 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index e915dd5..9faedf1 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+2016-03-27 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/decl.c (components_to_record): Add special case for
+ single field with representation clause at offset 0.
+
2016-03-16 Svante Signell <svante.signell@gmail.com>
* gcc-interface/Makefile.in: Add support for x86 GNU/Hurd.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 4b0ce28..ad84528 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -7606,6 +7606,23 @@ components_to_record (tree gnu_record_type, Node_Id gnat_component_list,
if (p_gnu_rep_list && gnu_rep_list)
*p_gnu_rep_list = chainon (*p_gnu_rep_list, gnu_rep_list);
+ /* If only one field has a rep clause and it starts at 0, put back the field
+ at the head of the regular field list. This will avoid creating a useless
+ REP part below and deal with the annoying case of an extension of a record
+ with variable size and rep clause, for which the _Parent field is forced
+ at offset 0 and has variable size, which we do not support below. */
+ else if (gnu_rep_list
+ && !DECL_CHAIN (gnu_rep_list)
+ && !variants_have_rep
+ && first_free_pos
+ && integer_zerop (first_free_pos)
+ && integer_zerop (bit_position (gnu_rep_list)))
+ {
+ DECL_CHAIN (gnu_rep_list) = gnu_field_list;
+ gnu_field_list = gnu_rep_list;
+ gnu_rep_list = NULL_TREE;
+ }
+
/* Otherwise, sort the fields by bit position and put them into their own
record, before the others, if we also have fields without rep clause. */
else if (gnu_rep_list)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a5f548f..44f023f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2016-03-27 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/specs/double_record_extension3.ads: New test.
+
2016-03-25 Richard Henderson <rth@redhat.com>
PR target/70120
diff --git a/gcc/testsuite/gnat.dg/specs/double_record_extension3.ads b/gcc/testsuite/gnat.dg/specs/double_record_extension3.ads
new file mode 100644
index 0000000..de53655
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/double_record_extension3.ads
@@ -0,0 +1,22 @@
+-- { dg-do compile }
+
+package Double_Record_Extension3 is
+
+ type Rec1 is tagged record
+ Id : Integer;
+ end record;
+
+ for Rec1 use record
+ Id at 8 range 0 .. 31;
+ end record;
+
+ type Rec2 (Size : Integer) is new Rec1 with record
+ Data : String (1 .. Size);
+ end record;
+
+ type Rec3 is new Rec2 (Size => 128) with record
+ Valid : Boolean;
+ end record;
+
+end Double_Record_Extension3;
+