+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.
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;
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)));
-------------------------------
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);
-- 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,
@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
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.
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
-- 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
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
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;
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;
--------------
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
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
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
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");