From f17aba3c82d9c316ab550b81cf9c7f141b31b999 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 21 Sep 2017 15:45:36 +0000 Subject: [PATCH] * stor-layout.c (bit_from_pos): Do not distribute the conversion. From-SVN: r253074 --- gcc/ChangeLog | 6 ++---- gcc/stor-layout.c | 10 +++------- gcc/testsuite/ChangeLog | 11 +++++++++++ gcc/testsuite/gnat.dg/discr48.adb | 9 +++++++++ gcc/testsuite/gnat.dg/discr48_pkg.ads | 19 +++++++++++++++++++ 5 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/discr48.adb create mode 100644 gcc/testsuite/gnat.dg/discr48_pkg.ads diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4c44002ee12..3071a86c717 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,8 +1,6 @@ -2017-09-21 Tamar Christina +2017-09-21 Eric Botcazou - 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 diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index a6d430760fc..938be6745af 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ea22ee833d..ce407c667b5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2017-09-21 Eric Botcazou + + * gnat.dg/discr48.adb: New test. + * gnat.dg/discr48_pkg.ads: New helper. + +2017-09-21 Tamar Christina + + PR testsuite/78421 + * lib/target-supports.exp (check_effective_target_vect_hw_misalign): + Invert arm check. + 2017-09-21 Cesar Philippidis * 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 index 00000000000..677f6ec67b1 --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr48.adb @@ -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 index 00000000000..646b4f11bd3 --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr48_pkg.ads @@ -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; -- 2.30.2