tree-sra.c (build_ref_for_offset_1): Skip fields without size or with size that can't be represented as a host integer.

* tree-sra.c (build_ref_for_offset_1) <RECORD_TYPE>: Skip fields
	without size or with size that can't be represented as a host integer.

From-SVN: r153008
This commit is contained in:
Eric Botcazou 2009-10-20 09:19:17 +00:00 committed by Eric Botcazou
parent 717f4048cd
commit a1aa17011f
6 changed files with 72 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2009-10-20 Eric Botcazou <ebotcazou@adacore.com>
* tree-sra.c (build_ref_for_offset_1) <RECORD_TYPE>: Skip fields
without size or with size that can't be represented as a host integer.
2009-10-20 Alexandre Oliva <aoliva@redhat.com>
* tree-ssa-dce.c (eliminate_unnecessary_stmts): Don't regard

View File

@ -1,3 +1,8 @@
2009-10-20 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/discr21.ad[sb]: New test.
* gnat.dg/discr21_pkg.ads: New helper.
2009-10-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/41706

View File

@ -0,0 +1,34 @@
-- { dg-do compile }
-- { dg-options "-gnatws -O3" }
with Discr21_Pkg; use Discr21_Pkg;
package body Discr21 is
type Index is new Natural range 0 .. 100;
type Arr is array (Index range <> ) of Position;
type Rec(Size : Index := 1) is record
A : Arr(1 .. Size);
end record;
Data : Rec;
function To_V(pos : Position) return VPosition is
begin
return To_Position(pos.x, pos.y, pos.z);
end;
procedure Read(Data : Rec) is
pos : VPosition := To_V (Data.A(1));
begin
null;
end;
procedure Test is
begin
Read (Data);
end;
end Discr21;

View File

@ -0,0 +1,5 @@
package Discr21 is
procedure Test;
end Discr21;

View File

@ -0,0 +1,19 @@
package Discr21_Pkg is
type Position is record
x,y,z : Float;
end record;
type Dim is (Two, Three);
type VPosition (D: Dim := Three) is record
x, y : Float;
case D is
when Two => null;
when Three => z : Float;
end case;
end record;
function To_Position (x, y, z : Float) return VPosition;
end Discr21_Pkg;

View File

@ -1243,7 +1243,10 @@ build_ref_for_offset_1 (tree *res, tree type, HOST_WIDE_INT offset,
pos = int_bit_position (fld);
gcc_assert (TREE_CODE (type) == RECORD_TYPE || pos == 0);
size = tree_low_cst (DECL_SIZE (fld), 1);
tr_size = DECL_SIZE (fld);
if (!tr_size || !host_integerp (tr_size, 1))
continue;
size = tree_low_cst (tr_size, 1);
if (pos > offset || (pos + size) <= offset)
continue;