diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-01-20 16:35:11 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-01-20 16:35:11 +0100 |
commit | d8a764c4fbaf9df22d41c00df4a2ec53355460d5 (patch) | |
tree | 51b0999be81a06ef65f8ab9ba8cfaba112cdf786 | |
parent | 818b578d1524f1aedf2c58ffe3b424023b2a79af (diff) | |
download | gcc-d8a764c4fbaf9df22d41c00df4a2ec53355460d5.zip gcc-d8a764c4fbaf9df22d41c00df4a2ec53355460d5.tar.gz gcc-d8a764c4fbaf9df22d41c00df4a2ec53355460d5.tar.bz2 |
[multiple changes]
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
-rw-r--r-- | gcc/ada/ChangeLog | 33 | ||||
-rw-r--r-- | gcc/ada/exp_ch3.adb | 4 | ||||
-rw-r--r-- | gcc/ada/exp_ch7.adb | 23 | ||||
-rw-r--r-- | gcc/ada/gnat_rm.texi | 7 | ||||
-rw-r--r-- | gcc/ada/gnat_ugn.texi | 7 | ||||
-rw-r--r-- | gcc/ada/opt.ads | 5 | ||||
-rw-r--r-- | gcc/ada/sem.adb | 12 | ||||
-rw-r--r-- | gcc/ada/sem_ch6.adb | 12 | ||||
-rw-r--r-- | gcc/ada/sem_prag.adb | 6 | ||||
-rw-r--r-- | gcc/ada/sem_res.adb | 2 | ||||
-rw-r--r-- | gcc/ada/switch-c.adb | 9 | ||||
-rw-r--r-- | gcc/ada/usage.adb | 5 |
12 files changed, 88 insertions, 37 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 9cba1cd..3e571ff 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,38 @@ 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. * gnat_rm.texi: Document pragma Allow_Integer_Address. * gnat_ugn.texi: Document pragma Allow_Integer_Address, -gnates. diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index f1ab0c5..087c791 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -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))); diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 25e4ef3..e1a1d87 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -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, diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 1d2a567..5e32e74 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -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 diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 42b8588..5acb851 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -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. diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 1641d87..58f0fe6 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -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 diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb index 6094b14..a175014 100644 --- a/gcc/ada/sem.adb +++ b/gcc/ada/sem.adb @@ -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 diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 52a81af..995d084 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -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; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index ef2c809..54ed0b1 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -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; -------------- diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 0dc75aa..c79c788 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -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 diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb index 369d0a6..0d80f44 100644 --- a/gcc/ada/switch-c.adb +++ b/gcc/ada/switch-c.adb @@ -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 diff --git a/gcc/ada/usage.adb b/gcc/ada/usage.adb index f7be313..3f566f4 100644 --- a/gcc/ada/usage.adb +++ b/gcc/ada/usage.adb @@ -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"); |