mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-21 08:30:35 +08:00
re PR ada/18817 (ACATS c380004 fails at run time)
PR ada/18817 * utils.c (max_size): Perform constant folding of (A ? B : C) - D into A ? B - D : C - D when calculating the size of a MINUS_EXPR. From-SVN: r116964
This commit is contained in:
parent
9bdb04a2f5
commit
21cc37194e
@ -1,3 +1,9 @@
|
||||
2006-09-15 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
PR ada/18817
|
||||
* utils.c (max_size): Perform constant folding of (A ? B : C) - D
|
||||
into A ? B - D : C - D when calculating the size of a MINUS_EXPR.
|
||||
|
||||
2006-09-13 Olivier Hainque <hainque@adacore.com>
|
||||
|
||||
PR ada/29025
|
||||
|
@ -2072,6 +2072,22 @@ max_size (tree exp, bool max_p)
|
||||
if (code == COMPOUND_EXPR)
|
||||
return max_size (TREE_OPERAND (exp, 1), max_p);
|
||||
|
||||
/* Calculate "(A ? B : C) - D" as "A ? B - D : C - D" which
|
||||
may provide a tighter bound on max_size. */
|
||||
if (code == MINUS_EXPR
|
||||
&& TREE_CODE (TREE_OPERAND (exp, 0)) == COND_EXPR)
|
||||
{
|
||||
tree lhs = fold_build2 (MINUS_EXPR, type,
|
||||
TREE_OPERAND (TREE_OPERAND (exp, 0), 1),
|
||||
TREE_OPERAND (exp, 1));
|
||||
tree rhs = fold_build2 (MINUS_EXPR, type,
|
||||
TREE_OPERAND (TREE_OPERAND (exp, 0), 2),
|
||||
TREE_OPERAND (exp, 1));
|
||||
return fold_build2 (max_p ? MAX_EXPR : MIN_EXPR, type,
|
||||
max_size (lhs, max_p),
|
||||
max_size (rhs, max_p));
|
||||
}
|
||||
|
||||
{
|
||||
tree lhs = max_size (TREE_OPERAND (exp, 0), max_p);
|
||||
tree rhs = max_size (TREE_OPERAND (exp, 1),
|
||||
|
@ -1,4 +1,3 @@
|
||||
c380004
|
||||
c52103x
|
||||
c52104x
|
||||
c52104y
|
||||
@ -7,6 +6,5 @@ cb1010c
|
||||
cb1010d
|
||||
templat
|
||||
# Tests must be sorted in alphabetical order
|
||||
# c380004: should be front-end compile time error, PR ada/18817
|
||||
# c52103x, c52104x, c52104y: -fstack-check doesn't work, PR middle-end/20548
|
||||
# cb1010a, cb1010c, cb1010d: likewise
|
||||
|
Loading…
x
Reference in New Issue
Block a user