+2014-01-20 Robert Dewar <dewar@adacore.com>
+
+ * gnat_rm.texi (Allow_Integer_Address): Remove note about not
+ allowed if address is non-private, no longer true.
+ * sem_prag.adb (Analyze_Pragma, case Allow_Integer_Address):
+ Remove check for address being private, causes difficulty when
+ pragma used in gnat.adc file and is not needed, since we guard
+ this in Address_Integer_Convert_OK.
+ * exp_ch7.adb: Minor reformatting.
+ * sem_ch4.adb: Handle operator operands in Allow_Integer_Address mode.
+
+2014-01-20 Robert Dewar <dewar@adacore.com>
+
+ * checks.adb (Apply_Range_Check): Remove gnatprove special
+ casing of exponentiation.
+ * sem_res.adb (Resolve_Op_Expon): Apply range check to right
+ operand for integer case to check range against Natural.
+
2014-01-20 Robert Dewar <dewar@adacore.com>
* s-tataat.adb: Minor reformatting.
return;
end if;
- -- Ensure that the exponent is a natural. The flag is set only in formal
- -- verification mode as the expander takes care of this check and there
- -- is no expansion phase in GNATprove_Mode.
-
- -- Doesn't seem right to do this unconditionally, we should check the
- -- range of the exponent operand. If we do that, it seems like we should
- -- then set the flag unconditionally and have the expander check the
- -- flag to see whether to generate a check ???
-
- if GNATprove_Mode and then Nkind (Expr) = N_Op_Expon then
- Set_Do_Range_Check (Right_Opnd (Expr));
- end if;
-
Is_Unconstrained_Subscr_Ref :=
Is_Subscr_Ref and then not Is_Constrained (Arr_Typ);
-- signalling the decision outcome occurs before the cleanup actions.
if Opt.Suppress_Control_Flow_Optimizations
- and then Is_Boolean_Type (Typ)
+ and then Is_Boolean_Type (Typ)
then
Expr :=
Make_If_Expression (Loc,
@end smallexample
@noindent
-This configuration pragma is allowed only
-if type @code{System.Address} is a private type,
-which is true in most versions of GNAT. which means that integer values,
+In almost all versions of GNAT, @code{System.Address} is a private
+type in accordance with the implementation advice in the RM. This
+means that integer values,
in particular integer literals, are not allowed as address values.
If the configuration pragma
@code{Allow_Integer_Address} is given, then integer expressions may
end AddrAsInt;
@end smallexample
-@noindent
-Note that these automatic conversions do not apply to expressions used
-as subprogram arguments, because in general overloading can take place,
-so that the required type is not fixed by the context. If necessary
-adjust the type of the subprogram argument, e.g. by adding a conversion.
-
@node Pragma Annotate
@unnumberedsec Pragma Annotate
@findex Annotate
N_Op_Rem,
N_Op_Subtract)
then
+ -- If Allow_Integer_Address is active, check whether the
+ -- operation becomes legal after converting an operand.
+
if Is_Numeric_Type (Etype (L))
and then not Is_Numeric_Type (Etype (R))
then
- Resolve (R, Etype (L));
+ if Address_Integer_Convert_OK (Etype (R), Etype (L)) then
+ Rewrite (R,
+ Unchecked_Convert_To (Etype (L), Relocate_Node (R)));
+ Analyze_Arithmetic_Op (N);
+
+ else
+ Resolve (R, Etype (L));
+ end if;
return;
elsif Is_Numeric_Type (Etype (R))
and then not Is_Numeric_Type (Etype (L))
then
- Resolve (L, Etype (R));
+ if Address_Integer_Convert_OK (Etype (L), Etype (R)) then
+ Rewrite (L,
+ Unchecked_Convert_To (Etype (R), Relocate_Node (L)));
+ Analyze_Arithmetic_Op (N);
+
+ else
+ Resolve (L, Etype (R));
+ end if;
return;
end if;
when Pragma_Allow_Integer_Address =>
GNAT_Pragma;
Check_Arg_Count (0);
-
- if not Is_Private_Type (RTE (RE_Address)) then
- Error_Pragma
- ("pragma% allowed only if Address is a private type");
- end if;
-
Opt.Allow_Integer_Address := True;
--------------
Resolve (Left_Opnd (N), B_Typ);
Resolve (Right_Opnd (N), Standard_Integer);
+ -- For integer types, right argument must be in Natural range
+
+ if Is_Integer_Type (Typ) then
+ Apply_Scalar_Range_Check (Right_Opnd (N), Standard_Natural);
+ end if;
+
Check_Unset_Reference (Left_Opnd (N));
Check_Unset_Reference (Right_Opnd (N));