* stor-layout.c (bit_from_pos): Do not distribute the conversion.
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 21 Sep 2017 15:45:36 +0000 (15:45 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 21 Sep 2017 15:45:36 +0000 (15:45 +0000)
From-SVN: r253074

gcc/ChangeLog
gcc/stor-layout.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/discr48.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/discr48_pkg.ads [new file with mode: 0644]

index 4c44002ee1287c69fa72373587138a9bf448a070..3071a86c7174464a9ad3968f4239413b780ef9e8 100644 (file)
@@ -1,8 +1,6 @@
-2017-09-21  Tamar Christina  <tamar.christina@arm.com>
+2017-09-21  Eric Botcazou  <ebotcazou@adacore.com>
 
-       PR testsuite/78421
-       * lib/target-supports.exp (check_effective_target_vect_hw_misalign):
-       Invert arm check.
+       * stor-layout.c (bit_from_pos): Do not distribute the conversion.
 
 2017-09-21  Segher Boessenkool  <segher@kernel.crashing.org>
 
index a6d430760fc4b376717df21b75f6131137a2c887..938be6745af4aaa7f146f3a66a54af28809cf7bf 100644 (file)
@@ -853,14 +853,10 @@ start_record_layout (tree t)
 tree
 bit_from_pos (tree offset, tree bitpos)
 {
-  if (TREE_CODE (offset) == PLUS_EXPR)
-    offset = size_binop (PLUS_EXPR,
-                        fold_convert (bitsizetype, TREE_OPERAND (offset, 0)),
-                        fold_convert (bitsizetype, TREE_OPERAND (offset, 1)));
-  else
-    offset = fold_convert (bitsizetype, offset);
   return size_binop (PLUS_EXPR, bitpos,
-                    size_binop (MULT_EXPR, offset, bitsize_unit_node));
+                    size_binop (MULT_EXPR,
+                                fold_convert (bitsizetype, offset),
+                                bitsize_unit_node));
 }
 
 /* Return the combined truncated byte position for the byte offset OFFSET and
index 1ea22ee833d0bc020cafbed01c43b601834c2805..ce407c667b5f6375a71810132f668269eb20241c 100644 (file)
@@ -1,3 +1,14 @@
+2017-09-21  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/discr48.adb: New test.
+       * gnat.dg/discr48_pkg.ads: New helper.
+
+2017-09-21  Tamar Christina  <tamar.christina@arm.com>
+
+       PR testsuite/78421
+       * lib/target-supports.exp (check_effective_target_vect_hw_misalign):
+       Invert arm check.
+
 2017-09-21  Cesar Philippidis  <cesar@codesourcery.com>
 
        * gfortran.dg/goacc/wait.f90: New test.
diff --git a/gcc/testsuite/gnat.dg/discr48.adb b/gcc/testsuite/gnat.dg/discr48.adb
new file mode 100644 (file)
index 0000000..677f6ec
--- /dev/null
@@ -0,0 +1,9 @@
+-- { dg-do compile }
+
+with Discr48_Pkg; use Discr48_Pkg;
+
+function Discr48 return Rec_Access is
+   C : constant Rec := (Count => 1, Seps => (1 .. 0 => Null_XString));
+begin
+   return new Rec'(C);
+end;
diff --git a/gcc/testsuite/gnat.dg/discr48_pkg.ads b/gcc/testsuite/gnat.dg/discr48_pkg.ads
new file mode 100644 (file)
index 0000000..646b4f1
--- /dev/null
@@ -0,0 +1,19 @@
+with Ada.Finalization;
+
+package Discr48_Pkg is
+
+   type XString is new Ada.Finalization.Controlled with record
+      B : Boolean;
+   end record;
+
+   Null_XString : constant XString := (Ada.Finalization.Controlled with B => False);
+
+   type XString_Array is array (Natural range <>) of XString;
+
+   type Rec (Count : Positive) is record
+      Seps : XString_Array (2 .. Count);
+   end record;
+
+   type Rec_Access is access all Rec;
+
+end Discr48_Pkg;