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

* 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.

2014-01-20  Ed Schonberg  <schonberg@adacore.com>

* sem_ch6.adb (Analyze_Expression_Function): Pre-analyze and
resolve expression to perform proper name capture.

2014-01-20  Ed Schonberg  <schonberg@adacore.com>

* sem.adb (Semantics): When saving/restoring configuration
switches, the spec of a pre- defined unit that is the main unit
must be treated as a predefined unit as well.

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

* exp_ch7.adb (Wrap_Transient_Expression): For a Boolean
expression, insert an extra conditional expression when saving
the value of the expression, for the benefit of control flow
graph based coverage analysis.
* exp_ch3.adb: Minor reformatting.

From-SVN: r206826

12 files changed:
gcc/ada/ChangeLog
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch7.adb
gcc/ada/gnat_rm.texi
gcc/ada/gnat_ugn.texi
gcc/ada/opt.ads
gcc/ada/sem.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_res.adb
gcc/ada/switch-c.adb
gcc/ada/usage.adb

index 9cba1cd67e9fa9ca48367a259d3ca6a7cf0e5e1f..3e571ff1193a2f3424e007a6cf0a607767a9c7e9 100644 (file)
@@ -1,3 +1,36 @@
+2014-01-20  Robert Dewar  <dewar@adacore.com>
+
+       * 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.
+
+2014-01-20  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch6.adb (Analyze_Expression_Function): Pre-analyze and
+       resolve expression to perform proper name capture.
+
+2014-01-20  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem.adb (Semantics): When saving/restoring configuration
+       switches, the spec of a pre- defined unit that is the main unit
+       must be treated as a predefined unit as well.
+
+2014-01-20  Thomas Quinot  <quinot@adacore.com>
+
+       * exp_ch7.adb (Wrap_Transient_Expression): For a Boolean
+       expression, insert an extra conditional expression when saving
+       the value of the expression, for the benefit of control flow
+       graph based coverage analysis.
+       * exp_ch3.adb: Minor reformatting.
+
 2014-01-20  Robert Dewar  <dewar@adacore.com>
 
        * gnat1drv.adb: Set Allow_Integer_Address in relaxed semantics mode.
index f1ab0c5e76557329b41d3ddd28b65ffb15ad0f43..087c79149c59842d8cfc49f4bc49556bdb908365 100644 (file)
@@ -941,7 +941,7 @@ package body Exp_Ch3 is
       Rec_Id            : Entity_Id;
       Loc               : Source_Ptr;
       Enclosing_Func_Id : Entity_Id;
-      Sequence          : Nat     := 1;
+      Sequence          : Nat := 1;
       Type_Def          : Node_Id;
       V                 : Node_Id;
 
@@ -984,7 +984,7 @@ package body Exp_Ch3 is
       begin
          Case_Node := New_Node (N_Case_Statement, Loc);
 
-         --  Replace the discriminant which controls the variant, with the name
+         --  Replace the discriminant which controls the variant with the name
          --  of the formal of the checking function.
 
          Set_Expression (Case_Node, Make_Identifier (Loc, Chars (Case_Id)));
index 25e4ef3c6247da8d086e6be84ebcc75e9f69d84f..e1a1d87771ad9e6da0350c35a461fc3877b7ca95 100644 (file)
@@ -7960,8 +7960,8 @@ package body Exp_Ch7 is
    -------------------------------
 
    procedure Wrap_Transient_Expression (N : Node_Id) is
-      Expr : constant Node_Id    := Relocate_Node (N);
       Loc  : constant Source_Ptr := Sloc (N);
+      Expr : Node_Id             := Relocate_Node (N);
       Temp : constant Entity_Id  := Make_Temporary (Loc, 'E', N);
       Typ  : constant Entity_Id  := Etype (N);
 
@@ -7972,14 +7972,31 @@ package body Exp_Ch7 is
       --    declare
       --       M : constant Mark_Id := SS_Mark;
       --       procedure Finalizer is ...  (See Build_Finalizer)
-
+      --
       --    begin
-      --       Temp := <Expr>;
+      --       Temp := <Expr>;                           --  general case
+      --       Temp := (if <Expr> then True else False); --  boolean case
       --
       --    at end
       --       Finalizer;
       --    end;
 
+      --  A special case is made for Boolean expressions so that the back-end
+      --  knows to generate a conditional branch instruction if running with
+      --  -fpreserve-control-flow. This ensures that a control flow change
+      --  signalling the decision outcome occurs before the cleanup actions.
+      --  In the absence of -fpreserve-control-flow, the back-end will
+      --  optimize away the extra conditional expression, so we can do this
+      --  modification unconditionally here.
+
+      if Is_Boolean_Type (Typ) then
+         Expr := Make_If_Expression (Loc,
+                   Expressions => New_List (
+                     Expr,
+                     New_Occurrence_Of (Standard_True, Loc),
+                     New_Occurrence_Of (Standard_False, Loc)));
+      end if;
+
       Insert_Actions (N, New_List (
         Make_Object_Declaration (Loc,
           Defining_Identifier => Temp,
index 1d2a567f24a393c81defc6e453fad6a6a27e78e4..5e32e74c99ce022375081d1e649da7e006dd94be 100644 (file)
@@ -1231,8 +1231,11 @@ 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
+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 42b858877e39aa68e05a774bd65554d81ed09993..5acb851375d624fac06c7ae4d3689bc2e6cc1a47 100644 (file)
@@ -3821,13 +3821,6 @@ 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 backwards compatibility.
index 1641d87dda5c9ee9f627d53faa814285513dd3cf..58f0fe6c57c731cdef669081dbe53696a618aa37 100644 (file)
@@ -191,9 +191,8 @@ package Opt is
    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 6094b14f438f571b868a6ca29fac8798e5e9e931..a17501424607681be6d772c9b73e9623e34a9151 100644 (file)
@@ -1322,6 +1322,16 @@ package body Sem is
       --  If the main unit is generic, every compiled unit, including its
       --  context, is compiled with expansion disabled.
 
+      --  configuration flags have special settings when compiling a predefined
+      --  file as a main unit. This applies to its spec as well.
+
+      Is_Main_Unit : constant Boolean :=
+         Current_Sem_Unit = Main_Unit
+           or else
+             (Nkind (Unit (Cunit (Main_Unit))) = N_Package_Body
+               and then Library_Unit (Cunit (Main_Unit)) =
+                  Cunit (Current_Sem_Unit));
+
       Ext_Main_Source_Unit : constant Boolean :=
                                In_Extended_Main_Source_Unit (Comp_Unit);
       --  Determine if unit is in extended main source unit
@@ -1421,7 +1431,7 @@ package body Sem is
       Save_Opt_Config_Switches (Save_Config_Switches);
       Set_Opt_Config_Switches
         (Is_Internal_File_Name (Unit_File_Name (Current_Sem_Unit)),
-         Current_Sem_Unit = Main_Unit);
+          Is_Main_Unit);
 
       --  Save current non-partition-wide restrictions
 
index 52a81af781bcd878c3049caf2faddb1c4005f82d..995d0840f1cecd1df7e721008e816759738e9ab5 100644 (file)
@@ -452,15 +452,17 @@ package body Sem_Ch6 is
             Push_Scope (Id);
             Install_Formals (Id);
 
-            --  Do a preanalysis of the expression on a separate copy, to
-            --  prevent visibility issues later with operators in instances.
-            --  Attach copy to tree so that parent links are available.
+            --  Preanalyze the expression for name capture, except in an
+            --  instance, where this has been done during generic analysis,
+            --  and will be redone when analyzing the body.
 
             declare
-               Expr : constant Node_Id := New_Copy_Tree (Expression (Ret));
+               Expr : Node_Id renames Expression (Ret);
             begin
                Set_Parent (Expr, Ret);
-               Preanalyze_Spec_Expression (Expr, Etype (Id));
+               if not In_Instance then
+                  Preanalyze_Spec_Expression (Expr, Etype (Id));
+               end if;
             end;
 
             End_Scope;
index ef2c80973dac80bb920a7b889fc3da6b2bfdd6a9..54ed0b1430b22eceaf30f95faa4332934a894e56 100644 (file)
@@ -9834,6 +9834,12 @@ package body Sem_Prag is
          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 0dc75aa0f1cf349240a19047d7f60b591fbddf85..c79c788e32d1d12fd6e8cb54f5059853e387d620 100644 (file)
@@ -2625,6 +2625,7 @@ package body Sem_Res is
                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 @@ package body Sem_Res is
       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 369d0a6a265e31e8327d5376ca79ddaa06ee60a1..0d80f44a3a55ca16268ab5537ed601d506031c80 100644 (file)
@@ -660,15 +660,6 @@ 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 f7be3136ffd3ec9817f00dd47a66a2d43d55e78d..3f566f47fb5687b76ae51adc8635d524e727d885 100644 (file)
@@ -236,11 +236,6 @@ 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");