summaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch4.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2015-05-22 12:51:36 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2015-05-22 12:51:36 +0000
commit36625869d3f0688597d79eed21cbb7459d70c0e7 (patch)
tree1338b17af8940144bc5deeefeb5dd2bebc22495e /gcc/ada/exp_ch4.adb
parentddbcfcd0c41776fced160b20099791b1911e5086 (diff)
downloadgcc-36625869d3f0688597d79eed21cbb7459d70c0e7.tar.gz
2015-05-22 Robert Dewar <dewar@adacore.com>
* exp_ch4.adb (Expand_N_Op_Eq): Introduce 'Machine for 'Result comparison. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223559 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/exp_ch4.adb')
-rw-r--r--gcc/ada/exp_ch4.adb24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 9f3be7eb272..df73482a4d5 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -7519,7 +7519,31 @@ package body Exp_Ch4 is
Rewrite_Comparison (N);
+ -- Special optimization of length comparison
+
Optimize_Length_Comparison (N);
+
+ -- One more special case, if we have a comparison of X'Result = expr
+ -- in floating-point, then if not already there, change expr to be
+ -- f'Machine (expr) to eliminate suprise from extra precision.
+
+ if Is_Floating_Point_Type (Typl)
+ and then Nkind (Original_Node (Lhs)) = N_Attribute_Reference
+ and then Attribute_Name (Original_Node (Lhs)) = Name_Result
+ then
+ -- Stick in the Typ'Machine call if not already there
+
+ if Nkind (Rhs) /= N_Attribute_Reference
+ or else Attribute_Name (Rhs) /= Name_Machine
+ then
+ Rewrite (Rhs,
+ Make_Attribute_Reference (Loc,
+ Prefix => New_Occurrence_Of (Typl, Loc),
+ Attribute_Name => Name_Machine,
+ Expressions => New_List (Relocate_Node (Rhs))));
+ Analyze_And_Resolve (Rhs, Typl);
+ end if;
+ end if;
end Expand_N_Op_Eq;
-----------------------