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:
parent
717f4048cd
commit
a1aa17011f
@ -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
|
||||
|
@ -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
|
||||
|
34
gcc/testsuite/gnat.dg/discr21.adb
Normal file
34
gcc/testsuite/gnat.dg/discr21.adb
Normal 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;
|
5
gcc/testsuite/gnat.dg/discr21.ads
Normal file
5
gcc/testsuite/gnat.dg/discr21.ads
Normal file
@ -0,0 +1,5 @@
|
||||
package Discr21 is
|
||||
|
||||
procedure Test;
|
||||
|
||||
end Discr21;
|
19
gcc/testsuite/gnat.dg/discr21_pkg.ads
Normal file
19
gcc/testsuite/gnat.dg/discr21_pkg.ads
Normal 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;
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user