This patch fixes a spurious error on an exponentation operand that has a
universal interpretation, when the parent node is overloaded and one of its
interpretations is a fixed-point type.
The following must compile quietly:
gcc -c adt.adb
with Sim;
package adt is
task type Cust;
end;
package sim is
type Sim_Duration is new Duration delta 1.0 / 60.0;
function "-"( x, y : sim_duration) return sim_duration;
type LARGE_INTEGER is delta 1.0 range -2.0**63 .. 2.0**63 - 1.0;
end sim;
package body adt is
task body Cust is
begin
null;
end;
end;
Tested on x86_64-pc-linux-gnu, committed on trunk
2011-08-29 Ed Schonberg <[email protected]>
* sem_res.adb (Resolve_Arithmetic_Op): If the node has a universal
interpretation, set the type before resolving the operands, because
legality checks on an exponention operand need to know the type of the
context.
Index: sem_res.adb
===================================================================
--- sem_res.adb (revision 178228)
+++ sem_res.adb (working copy)
@@ -4640,13 +4640,16 @@
-- universal real, since in this case we don't do a conversion to a
-- specific fixed-point type (instead the expander handles the case).
+ -- Set the type of the node to its universal interpretation because
+ -- legality checks on an exponentiation operand need the context.
+
elsif (B_Typ = Universal_Integer or else B_Typ = Universal_Real)
and then Present (Universal_Interpretation (L))
and then Present (Universal_Interpretation (R))
then
+ Set_Etype (N, B_Typ);
Resolve (L, Universal_Interpretation (L));
Resolve (R, Universal_Interpretation (R));
- Set_Etype (N, B_Typ);
elsif (B_Typ = Universal_Real
or else Etype (N) = Universal_Fixed