The switch -gnates is no longer available, this mode must be set
using the configuration pragma, or -gnatd.M or is set automatically
in CodePeer mode. The pragma is now only allowed if Address is a
private type (since otherwise it makes no sense), and finally an
error is corrected which caused the following test to fail:
Given the following gnat.adc file:
pragma Extend_System (Aux_AAMP);
where s-auxaam.ads contains the declarations:
function "+" (Left : Address; Right : Integer) return Address;
function "+" (Left : Integer; Right : Address) return Address;
function "-" (Left : Address; Right : Integer) return Address;
function "-" (Left : Integer; Right : Address) return Address;
function "-" (Left : Address; Right : Address) return Integer;
The following should compile silently with -gnatd.M
1. with System; use System;
2. package Sys is
3. Variable1 : Integer;
4. for Variable1 use at 16#43FFF0#;
5. Variable2 : System.Address;
6. Start_Address : constant System.Address := 16#1234#;
7. Max_Words : constant := 32;
8. Addr : System.Address :=
9. System.Address (Start_Address + Max_Words);
10. App_Start : System.Address := Variable1'Address;
11. App_End : System.Address := Variable2'Address;
12. App_Block_Size : constant System.Address :=
13. (App_End - App_Start + 1);
14. end Sys;
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-01-20 Robert Dewar <[email protected]>
* gnat_rm.texi: Document that Allow_Integer_Address is permitted
only if System.Address is a private type.
* opt.ads (Allow_Integer_Address): No longer set by -gnates.
* sem_prag.adb (Analyze_Pragma, case Allow_Integer_Address):
Allowed only if type System.Address is private, since otherwise
it makes no sense.
* sem_res.adb: Fix failure to properly Analyze unchecked
conversions that were introduced by Allow_Integer_Address.
* switch-c.adb: Remove -gnates switch.
* usage.adb: Remove -gnates switch.
* gnat_ugn.texi: Remove documentation of -gnates flag.
Index: gnat_rm.texi
===================================================================
--- gnat_rm.texi (revision 206825)
+++ gnat_rm.texi (working copy)
@@ -1231,8 +1231,11 @@
@end smallexample
@noindent
-In most versions of GNAT, @code{System.Address} is a private type, which means
-that integer values are not allowed. If the configuration pragma
+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 particular integer literals, are not allowed as address values.
+If the configuration pragma
@code{Allow_Integer_Address} is given, then integer expressions may
be used anywhere a value of type @code{System.Address} is required.
The effect is to introduce an implicit unchecked conversion from the
Index: gnat_ugn.texi
===================================================================
--- gnat_ugn.texi (revision 206825)
+++ gnat_ugn.texi (working copy)
@@ -3821,13 +3821,6 @@
manner). This can be useful in some specialized circumstances such as the
temporary use of special test software.
-@ifclear vms
-@item -gnates
-@cindex @option{-gnates} (@command{gcc})
-Activates @code{Allow_Integer_Address} mode as though the corresponding
-configuration pragma was present.
-@end ifclear
-
@item -gnateS
@cindex @option{-gnateS} (@command{gcc})
Synonym of @option{-fdump-scos}, kept for backwards compatibility.
Index: opt.ads
===================================================================
--- opt.ads (revision 206825)
+++ opt.ads (working copy)
@@ -191,9 +191,8 @@
Allow_Integer_Address : Boolean := False;
-- GNAT
-- Allow use of integer expression in a context requiring System.Address.
- -- Set by the use of configuration pragma Allow_Integer_Address, or the
- -- compiler switch -gnates. Also set in relaxed semantics mode for use
- -- by CodePeer.
+ -- Set by the use of configuration pragma Allow_Integer_Address Also set
+ -- in relaxed semantics mode for use by CodePeer or when -gnatd.M is used.
All_Sources : Boolean := False;
-- GNATBIND
Index: sem_prag.adb
===================================================================
--- sem_prag.adb (revision 206825)
+++ sem_prag.adb (working copy)
@@ -9834,6 +9834,12 @@
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;
--------------
Index: sem_res.adb
===================================================================
--- sem_res.adb (revision 206825)
+++ sem_res.adb (working copy)
@@ -2625,6 +2625,7 @@
Rewrite
(N, Unchecked_Convert_To (RTE (RE_Address),
Relocate_Node (N)));
+ Analyze_And_Resolve (N, RTE (RE_Address));
return;
-- OK, not the special case go ahead and issue message
@@ -11645,6 +11646,7 @@
then
Rewrite (N,
Unchecked_Convert_To (RTE (RE_Address), Relocate_Node (N)));
+ Analyze_And_Resolve (N, RTE (RE_Address));
return True;
-- Here we have a real conversion error
Index: switch-c.adb
===================================================================
--- switch-c.adb (revision 206825)
+++ switch-c.adb (working copy)
@@ -660,15 +660,6 @@
when 'P' =>
Treat_Categorization_Errors_As_Warnings := True;
- -- -gnates (allow integer expression for System.Address)
-
- -- Note: there is no VMS equivalent for this switch, since
- -- in VMS, System.Address is an integer type in any case.
-
- when 's' =>
- Allow_Integer_Address := True;
- Ptr := Ptr + 1;
-
-- -gnateS (generate SCO information)
-- Include Source Coverage Obligation information in ALI
Index: usage.adb
===================================================================
--- usage.adb (revision 206825)
+++ usage.adb (working copy)
@@ -236,11 +236,6 @@
Write_Switch_Char ("eP");
Write_Line ("Pure/Prelaborate errors generate warnings rather than errors");
- -- Line fofr -gnates switch
-
- Write_Switch_Char ("es");
- Write_Line ("Allow integer expression for System.Address value");
-
-- Line for -gnateS switch
Write_Switch_Char ("eS");