[Ada] Better expansion of short-circuit, conditional expressions
Arnaud Charlet
charlet@adacore.com
Fri Jun 18 11:37:00 GMT 2010
This patch enables use of the new N_Expression_With_Actions node
by default when using the gcc back end. The following test program:
procedure ExprActions (A, B, C : Natural; M, N : String) is
begin
if (A = 23 and then M (1 .. A) = N (1 .. B))
or else M (A .. B) = M (B .. C)
then
null;
end if;
end ExprActions;
Now generates the following -gnatG output by default (previous to this
patch, this output required the use of the -gnatd.X switch).
procedure expractions (a : natural; b : natural; c : natural; m :
string; n : string) is
subtype expractions__S2b is string (n'first(1) .. n'last(1));
subtype expractions__S1b is string (m'first(1) .. m'last(1));
begin
if (a = 23 and then
do
[constraint_error when
a >= 1 and then (1 < m'first(1) or else integer(a) > m'last(
1))
"range check failed"]
[subtype expractions__T3b is integer range 1 .. a]
[subtype expractions__T4b is string (expractions__T3b)]
reference expractions__T4b[constraint_error when
b >= 1 and then (1 < n'first(1) or else integer(b) > n'last(
1))
"range check failed"]
[subtype expractions__T5b is integer range 1 .. b]
[subtype expractions__T6b is string (expractions__T5b)]
reference expractions__T6b
in m (1 .. a) = n (1 .. b) end
) or else
do
[constraint_error when
b >= a and then (integer(a) < m'first(1) or else integer(b) >
m'last(1))
"range check failed"]
[subtype expractions__T7b is integer range a .. b]
[subtype expractions__T8b is string (expractions__T7b)]
reference expractions__T8b[constraint_error when
c >= b and then (integer(b) < m'first(1) or else integer(c) >
m'last(1))
"range check failed"]
[subtype expractions__T9b is integer range b .. c]
[subtype expractions__T10b is string (expractions__T9b)]
reference expractions__T10b
in m (a .. b) = m (b .. c) end
then
null;
end if;
return;
end expractions;
Tested on x86_64-pc-linux-gnu, committed on trunk
2010-06-18 Robert Dewar <dewar@adacore.com>
* gnat1drv.adb (Adjust_Global_Switches): Set Use_Expression_With_Actions
true for gcc.
-------------- next part --------------
Index: gnat1drv.adb
===================================================================
--- gnat1drv.adb (revision 160971)
+++ gnat1drv.adb (working copy)
@@ -353,11 +353,11 @@ procedure Gnat1drv is
then
Use_Expression_With_Actions := False;
- -- Otherwise normal gcc back end, for now still turn usage off by
- -- default.
+ -- Otherwise normal gcc back end, which does implement this feature
+ -- so by default we allow its use.
else
- Use_Expression_With_Actions := False;
+ Use_Expression_With_Actions := True;
end if;
-- Set switch indicating if back end can handle limited types, and
More information about the Gcc-patches
mailing list