aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Dewar <dewar@adacore.com>2007-12-13 11:23:01 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2007-12-13 11:23:01 +0100
commit16a55e63a98590ef71a37ff61c828c6b16bd75fb (patch)
tree9fdfda59626fff7ba3e443019f6a3d6db94d3421
parent31897c04da0668370ffd77e938d93b681213d0c5 (diff)
downloadgcc-16a55e63a98590ef71a37ff61c828c6b16bd75fb.zip
gcc-16a55e63a98590ef71a37ff61c828c6b16bd75fb.tar.gz
gcc-16a55e63a98590ef71a37ff61c828c6b16bd75fb.tar.bz2
checks.adb: Fix optimization problem with short-circuited form
2007-12-06 Robert Dewar <dewar@adacore.com> * checks.adb: Fix optimization problem with short-circuited form From-SVN: r130823
-rw-r--r--gcc/ada/checks.adb40
1 files changed, 30 insertions, 10 deletions
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index f9f0c10..7395594 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -2501,20 +2501,45 @@ package body Checks is
P := Parent (N);
K := Nkind (P);
- if K not in N_Subexpr then
+ -- Done if out of subexpression (note that we allow generated stuff
+ -- such as itype declarations in this context, to keep the loop going
+ -- since we may well have generated such stuff in complex situations.
+ -- Also done if no parent (probably an error condition, but no point
+ -- in behaving nasty if we find it!)
+
+ if No (P)
+ or else (K not in N_Subexpr and then Comes_From_Source (P))
+ then
return True;
- -- Or/Or Else case, left operand must be equality test
+ -- Or/Or Else case, where test is part of the right operand, or is
+ -- part of one of the actions associated with the right operand, and
+ -- the left operand is an equality test.
- elsif K = N_Op_Or or else K = N_Or_Else then
+ elsif K = N_Op_Or then
exit when N = Right_Opnd (P)
and then Nkind (Left_Opnd (P)) = N_Op_Eq;
- -- And/And then case, left operand must be inequality test
+ elsif K = N_Or_Else then
+ exit when (N = Right_Opnd (P)
+ or else
+ (Is_List_Member (N)
+ and then List_Containing (N) = Actions (P)))
+ and then Nkind (Left_Opnd (P)) = N_Op_Eq;
- elsif K = N_Op_And or else K = N_And_Then then
+ -- Similar test for the And/And then case, where the left operand
+ -- is an inequality test.
+
+ elsif K = N_Op_And then
exit when N = Right_Opnd (P)
and then Nkind (Left_Opnd (P)) = N_Op_Ne;
+
+ elsif K = N_And_Then then
+ exit when (N = Right_Opnd (P)
+ or else
+ (Is_List_Member (N)
+ and then List_Containing (N) = Actions (P)))
+ and then Nkind (Left_Opnd (P)) = N_Op_Ne;
end if;
N := P;
@@ -2524,11 +2549,6 @@ package body Checks is
-- appropriate test as its left operand. So test further.
L := Left_Opnd (P);
-
- if Nkind (L) = N_Op_Not then
- L := Right_Opnd (L);
- end if;
-
R := Right_Opnd (L);
L := Left_Opnd (L);