stor-layout.c (skip_simple_constant_arithmetic): New function.
* stor-layout.c (skip_simple_constant_arithmetic): New function. (self_referential_size): Use it instead of skip_simple_arithmetic. From-SVN: r165716
This commit is contained in:
parent
73dd5ce0c3
commit
0d475ac5b4
6 changed files with 87 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
2010-10-20 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* stor-layout.c (skip_simple_constant_arithmetic): New function.
|
||||
(self_referential_size): Use it instead of skip_simple_arithmetic.
|
||||
|
||||
2010-10-20 Olivier Hainque <hainque@adacore.com>
|
||||
|
||||
* config/rs6000/rs6000.c (rs6000_reg_live_or_pic_offset_p):
|
||||
|
|
|
@ -173,6 +173,32 @@ variable_size (tree size)
|
|||
/* An array of functions used for self-referential size computation. */
|
||||
static GTY(()) VEC (tree, gc) *size_functions;
|
||||
|
||||
/* Look inside EXPR into simple arithmetic operations involving constants.
|
||||
Return the outermost non-arithmetic or non-constant node. */
|
||||
|
||||
static tree
|
||||
skip_simple_constant_arithmetic (tree expr)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (UNARY_CLASS_P (expr))
|
||||
expr = TREE_OPERAND (expr, 0);
|
||||
else if (BINARY_CLASS_P (expr))
|
||||
{
|
||||
if (TREE_CONSTANT (TREE_OPERAND (expr, 1)))
|
||||
expr = TREE_OPERAND (expr, 0);
|
||||
else if (TREE_CONSTANT (TREE_OPERAND (expr, 0)))
|
||||
expr = TREE_OPERAND (expr, 1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
/* Similar to copy_tree_r but do not copy component references involving
|
||||
PLACEHOLDER_EXPRs. These nodes are spotted in find_placeholder_in_expr
|
||||
and substituted in substitute_in_expr. */
|
||||
|
@ -241,7 +267,7 @@ self_referential_size (tree size)
|
|||
VEC(tree,gc) *args = NULL;
|
||||
|
||||
/* Do not factor out simple operations. */
|
||||
t = skip_simple_arithmetic (size);
|
||||
t = skip_simple_constant_arithmetic (size);
|
||||
if (TREE_CODE (t) == CALL_EXPR)
|
||||
return size;
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2010-10-20 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gnat.dg/discr25.adb: New test.
|
||||
* gnat.dg/discr25_pkg.ad[sb]: New helper.
|
||||
|
||||
2010-10-20 Olivier Hainque <hainque@adacore.com>
|
||||
|
||||
* gcc.target/powerpc/ehreturn.c: New test.
|
||||
|
|
11
gcc/testsuite/gnat.dg/discr25.adb
Normal file
11
gcc/testsuite/gnat.dg/discr25.adb
Normal file
|
@ -0,0 +1,11 @@
|
|||
-- { dg-do compile }
|
||||
|
||||
with Discr25_Pkg;
|
||||
|
||||
procedure Discr25 (N : Natural) is
|
||||
|
||||
package Test_Set is new Discr25_Pkg (N);
|
||||
|
||||
begin
|
||||
null;
|
||||
end;
|
24
gcc/testsuite/gnat.dg/discr25_pkg.adb
Normal file
24
gcc/testsuite/gnat.dg/discr25_pkg.adb
Normal file
|
@ -0,0 +1,24 @@
|
|||
package body Discr25_Pkg is
|
||||
|
||||
type Arr1 is array (Natural range <>) of Integer;
|
||||
|
||||
B : constant Boolean := N > 0;
|
||||
|
||||
type Arr2 is array (True .. B) of Integer;
|
||||
|
||||
type Obj_T (Size_Max : Natural) is record
|
||||
A2 : Arr2;
|
||||
A1 : Arr1 (0 .. Size_Max);
|
||||
end record;
|
||||
|
||||
procedure Proc1 (Set : in out T) is
|
||||
begin
|
||||
Set := new Obj_T'(Set.all);
|
||||
end;
|
||||
|
||||
procedure Proc2 (Obj : in out T; L : Natural) is
|
||||
begin
|
||||
Obj := new Obj_T (L);
|
||||
end;
|
||||
|
||||
end Discr25_Pkg;
|
15
gcc/testsuite/gnat.dg/discr25_pkg.ads
Normal file
15
gcc/testsuite/gnat.dg/discr25_pkg.ads
Normal file
|
@ -0,0 +1,15 @@
|
|||
generic
|
||||
|
||||
N : Natural;
|
||||
|
||||
package Discr25_Pkg is
|
||||
|
||||
type T is private;
|
||||
|
||||
procedure Proc1 (Set : in out T);
|
||||
|
||||
private
|
||||
type Obj_T (Size_Max : Natural);
|
||||
type T is access Obj_T;
|
||||
|
||||
end Discr25_Pkg;
|
Loading…
Add table
Reference in a new issue