]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 20 Jan 2014 15:31:59 +0000 (16:31 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 20 Jan 2014 15:31:59 +0000 (16:31 +0100)
2014-01-20  Robert Dewar  <dewar@adacore.com>

* gnat1drv.adb: Set Allow_Integer_Address in relaxed semantics mode.
* gnat_rm.texi: Document pragma Allow_Integer_Address.
* gnat_ugn.texi: Document pragma Allow_Integer_Address, -gnates.
* opt.ads: New flag Allow_Integer_Address.
* par-prag.adb: Dummy entry for pragma Allow_Integer_Address.
* sem_ch5.adb: Minor reformatting.
* sem_prag.adb: Implement pragma Allow_Integer_Address.
* sem_res.adb (Resolve): Allow integer address value if
switch set.
* sem_util.adb: Minor reformatting.
* snames.ads-tmpl: Add entry for pragma Allow_Integer_Address.
* switch-c.adb: Recognize flag -gnates.
* usage.adb: Document flag -gnates.

2014-01-20  Thomas Quinot  <quinot@adacore.com>

* s-tadeca.adb: Fix minor typos in comment.

From-SVN: r206825

14 files changed:
gcc/ada/ChangeLog
gcc/ada/gnat1drv.adb
gcc/ada/gnat_rm.texi
gcc/ada/gnat_ugn.texi
gcc/ada/opt.ads
gcc/ada/par-prag.adb
gcc/ada/s-tadeca.adb
gcc/ada/sem_ch5.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_res.adb
gcc/ada/sem_util.adb
gcc/ada/snames.ads-tmpl
gcc/ada/switch-c.adb
gcc/ada/usage.adb

index 41edf88e47a42b3c9f95d0ca86dd2da08006b1f5..9cba1cd67e9fa9ca48367a259d3ca6a7cf0e5e1f 100644 (file)
@@ -1,3 +1,23 @@
+2014-01-20  Robert Dewar  <dewar@adacore.com>
+
+       * gnat1drv.adb: Set Allow_Integer_Address in relaxed semantics mode.
+       * gnat_rm.texi: Document pragma Allow_Integer_Address.
+       * gnat_ugn.texi: Document pragma Allow_Integer_Address, -gnates.
+       * opt.ads: New flag Allow_Integer_Address.
+       * par-prag.adb: Dummy entry for pragma Allow_Integer_Address.
+       * sem_ch5.adb: Minor reformatting.
+       * sem_prag.adb: Implement pragma Allow_Integer_Address.
+       * sem_res.adb (Resolve): Allow integer address value if
+       switch set.
+       * sem_util.adb: Minor reformatting.
+       * snames.ads-tmpl: Add entry for pragma Allow_Integer_Address.
+       * switch-c.adb: Recognize flag -gnates.
+       * usage.adb: Document flag -gnates.
+
+2014-01-20  Thomas Quinot  <quinot@adacore.com>
+
+       * s-tadeca.adb: Fix minor typos in comment.
+
 2014-01-20  Pascal Obry  <obry@adacore.com>
 
        * s-win32.ads (FreeLibrary): New import.
index 19df9fd7694a5c0e32563688e001e7044d644d1a..bc1de747dc6eddc99b79cbd8965cfe21ec437d4e 100644 (file)
@@ -293,6 +293,7 @@ procedure Gnat1drv is
       --  semantics mode.
 
       if Relaxed_RM_Semantics then
+         Opt.Allow_Integer_Address := True;
          Overriding_Renamings := True;
          Treat_Categorization_Errors_As_Warnings := True;
       end if;
index 465da2b0ebb977b556b3b974a146a626b930b05b..1d2a567f24a393c81defc6e453fad6a6a27e78e4 100644 (file)
@@ -104,6 +104,7 @@ Implementation Defined Pragmas
 * Pragma Ada_2005::
 * Pragma Ada_12::
 * Pragma Ada_2012::
+* Pragma Allow_Integer_Address::
 * Pragma Annotate::
 * Pragma Assert::
 * Pragma Assert_And_Cut::
@@ -276,6 +277,7 @@ Implementation Defined Aspects
 * Aspect Abstract_State::
 * Aspect Ada_2005::
 * Aspect Ada_2012::
+* Pragma Allow_Integer_Address::
 * Aspect Compiler_Unit::
 * Aspect Contract_Cases::
 * Aspect Depends::
@@ -927,6 +929,7 @@ consideration, the use of these pragmas should be minimized.
 * Pragma Ada_2005::
 * Pragma Ada_12::
 * Pragma Ada_2012::
+* Pragma Allow_Integer_Address::
 * Pragma Annotate::
 * Pragma Assert::
 * Pragma Assert_And_Cut::
@@ -1218,6 +1221,42 @@ pragma Ada_2012;
 This configuration pragma is a synonym for pragma Ada_12 and has the
 same syntax and effect.
 
+@node Pragma Allow_Integer_Address
+@unnumberedsec Pragma Allow_Integer_Address
+@findex Allow_Integer_Address
+@noindent
+Syntax:
+@smallexample @c ada
+pragma Allow_Integer_Address;
+@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
+@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
+integer value to type @code{System.Address}. The following example
+compiles without errors:
+
+@smallexample @c ada
+pragma Allow_Integer_Address;
+with System; use System;
+package AddrAsInt is
+   X : Integer;
+   Y : Integer;
+   for X'Address use 16#1240#;
+   for Y use at 16#3230#;
+   m : Address := 16#4000#;
+   n : constant Address := 4000;
+   p : constant Address := Address (X + Y);
+   type R is new integer;
+   RR : R := 1000;
+   Z : Integer;
+   for Z'Address use RR;
+end AddrAsInt;
+@end smallexample
+
 @node Pragma Annotate
 @unnumberedsec Pragma Annotate
 @findex Annotate
index 32a7e0f0dee64b0a3fdf5ab8013a79154d29eda4..42b858877e39aa68e05a774bd65554d81ed09993 100644 (file)
@@ -3821,9 +3821,16 @@ these errors become warnings (which can be ignored, or suppressed in the usual
 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 backards compatibility.
+Synonym of @option{-fdump-scos}, kept for backwards compatibility.
 
 @item -gnatet=@var{path}
 @cindex @option{-gnatet=file} (@command{gcc})
@@ -11778,6 +11785,7 @@ recognized by GNAT:
    Ada_2005
    Ada_12
    Ada_2012
+   Allow_Integer_Address
    Annotate
    Assertion_Policy
    Assume_No_Invalid_Values
@@ -22818,6 +22826,8 @@ following:
 
 @item  @code{Ada_2012}
 
+@item  @code{ALLOW_INTEGER_ADDRESS}
+
 @item  @code{ANNOTATE}
 
 @item  @code{ASSERT}
index ba486809a89b34f261faece56847767938a5d729..1641d87dda5c9ee9f627d53faa814285513dd3cf 100644 (file)
@@ -188,6 +188,13 @@ package Opt is
    --  also repeated error messages for references to undefined identifiers
    --  and certain other repeated error messages. Set by use of -gnatf.
 
+   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.
+
    All_Sources : Boolean := False;
    --  GNATBIND
    --  Set to True to require all source files to be present. This flag is
index 4cb9fd16ad4e5b8371a83ddb3db56b13e748b452..8e8674327173c89e129422daf658898f56a246d7 100644 (file)
@@ -1114,6 +1114,7 @@ begin
            Pragma_Assume_No_Invalid_Values       |
            Pragma_AST_Entry                      |
            Pragma_All_Calls_Remote               |
+           Pragma_Allow_Integer_Address          |
            Pragma_Annotate                       |
            Pragma_Assert                         |
            Pragma_Assert_And_Cut                 |
index 99fbe1450b31948060db0872a0931b88a7f0eeed..6faf4d04d6c991c658db5277318569bdcaf296b2 100644 (file)
@@ -55,7 +55,7 @@ begin
    end if;
 
    --  T is expressed as a duration elapsed since the UNIX epoch, whereas
-   --  Time_Enque expects duraction elapsed since the epoch of the Ada real-
+   --  Time_Enqueue expects duration elapsed since the epoch of the Ada real-
    --  time clock: compensate if necessary.
 
    --  Comparison "SOSC.CLOCK_RT_Ada = SOSC.CLOCK_REALTIME" is compile
index 3b0d1369abd761c1266499401aee4b7ead03a634..788ff89b7824510a683cb4ad6ed16e6d68f71035 100644 (file)
@@ -1695,8 +1695,8 @@ package body Sem_Ch5 is
 
       Set_Ekind (Def_Id, E_Variable);
 
-      --  Provide a link between the iterator variable and the container,
-      --  for subequent use in cross-reference and modification information.
+      --  Provide a link between the iterator variable and the container, for
+      --  subsequent use in cross-reference and modification information.
 
       if Of_Present (N) then
          Set_Related_Expression (Def_Id, Iter_Name);
index e678c8b6860b13d507012cdb4b05f89669dc37ce..ef2c80973dac80bb920a7b889fc3da6b2bfdd6a9 100644 (file)
@@ -9825,6 +9825,17 @@ package body Sem_Prag is
             end if;
          end All_Calls_Remote;
 
+         ---------------------------
+         -- Allow_Integer_Address --
+         ---------------------------
+
+         --  pragma Allow_Integer_Address;
+
+         when Pragma_Allow_Integer_Address =>
+            GNAT_Pragma;
+            Check_Arg_Count (0);
+            Opt.Allow_Integer_Address := True;
+
          --------------
          -- Annotate --
          --------------
@@ -22874,6 +22885,7 @@ package body Sem_Prag is
       Pragma_Ada_12                         => -1,
       Pragma_Ada_2012                       => -1,
       Pragma_All_Calls_Remote               => -1,
+      Pragma_Allow_Integer_Address          => 0,
       Pragma_Annotate                       => -1,
       Pragma_Assert                         => -1,
       Pragma_Assert_And_Cut                 => -1,
index 07a3c4a49805c908bf88f7c5218f7f4e0497f9f0..0dc75aa0f1cf349240a19047d7f60b591fbddf85 100644 (file)
@@ -2615,7 +2615,21 @@ package body Sem_Res is
             --  If an error message was issued already, Found got reset to
             --  True, so if it is still False, issue standard Wrong_Type msg.
 
-            if not Found then
+            --  First check for special case of Address wanted, integer found
+            --  with the configuration pragma Allow_Integer_Address active.
+
+            if Allow_Integer_Address
+              and then Is_RTE (Typ, RE_Address)
+              and then Is_Integer_Type (Etype (N))
+            then
+               Rewrite
+                 (N, Unchecked_Convert_To (RTE (RE_Address),
+                  Relocate_Node (N)));
+               return;
+
+            --  OK, not the special case go ahead and issue message
+
+            elsif not Found then
                if Is_Overloaded (N)
                  and then Nkind (N) = N_Function_Call
                then
@@ -11622,6 +11636,19 @@ package body Sem_Res is
             ("add ALL to }!", N, Target_Type);
          return False;
 
+      --  Deal with conversion of integer type to address if the pragma
+      --  Allow_Integer_Address is in effect.
+
+      elsif Allow_Integer_Address
+        and then Is_RTE (Etype (N), RE_Address)
+        and then Is_Integer_Type (Etype (Operand))
+      then
+         Rewrite (N,
+           Unchecked_Convert_To (RTE (RE_Address), Relocate_Node (N)));
+         return True;
+
+      --  Here we have a real conversion error
+
       else
          Conversion_Error_NE
            ("invalid conversion, not compatible with }", N, Opnd_Type);
index e9722a3f076a6a0177be149036d43e5ad3cbce42..905eabb89c58c1e04a3763f8c3e76fd830e1fc99 100644 (file)
@@ -13081,7 +13081,7 @@ package body Sem_Util is
 
                   if Present (Related_Expression (Ent))
                     and then Nkind (Parent (Related_Expression (Ent))) =
-                      N_Iterator_Specification
+                                                   N_Iterator_Specification
                   then
                      Exp := Original_Node (Related_Expression (Ent));
                   end if;
index 0be49580d98b947644cfcbb6073f3af39c2d52d8..576d89ee3aefb318cb38bd77aebdc832d465421d 100644 (file)
@@ -361,6 +361,7 @@ package Snames is
    Name_Ada_2005                       : constant Name_Id := N + $; -- GNAT
    Name_Ada_12                         : constant Name_Id := N + $; -- GNAT
    Name_Ada_2012                       : constant Name_Id := N + $; -- GNAT
+   Name_Allow_Integer_Address          : constant Name_Id := N + $; -- GNAT
    Name_Annotate                       : constant Name_Id := N + $; -- GNAT
    Name_Assertion_Policy               : constant Name_Id := N + $; -- Ada 05
    Name_Assume                         : constant Name_Id := N + $; -- GNAT
@@ -1709,6 +1710,7 @@ package Snames is
       Pragma_Ada_2005,
       Pragma_Ada_12,
       Pragma_Ada_2012,
+      Pragma_Allow_Integer_Address,
       Pragma_Annotate,
       Pragma_Assertion_Policy,
       Pragma_Assume,
index 0d80f44a3a55ca16268ab5537ed601d506031c80..369d0a6a265e31e8327d5376ca79ddaa06ee60a1 100644 (file)
@@ -660,6 +660,15 @@ package body Switch.C is
                   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 3f566f47fb5687b76ae51adc8635d524e727d885..f7be3136ffd3ec9817f00dd47a66a2d43d55e78d 100644 (file)
@@ -236,6 +236,11 @@ begin
    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");