From: Arnaud Charlet Date: Fri, 23 Oct 2015 12:52:53 +0000 (+0200) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a1c09064183ef120c05fb6ded552029ca79dbff9;p=gcc.git [multiple changes] 2015-10-23 Gary Dismukes * exp_ch6.adb: Minor reformatting. 2015-10-23 Ed Schonberg * sem_ch12.adb (Check_Formal_Packages): A formal package whose actual part is (others => <>) os identical to a formal package with an actual part written as (<>). 2015-10-23 Arnaud Charlet * a-reatim.adb ("/"): For Time_Span division convert the operands to integers and then use integer division, which conforms to the rounding required by Ada RM. From-SVN: r229250 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 8bc9fb5cdca..eab0d4cf872 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,19 @@ +2015-10-23 Gary Dismukes + + * exp_ch6.adb: Minor reformatting. + +2015-10-23 Ed Schonberg + + * sem_ch12.adb (Check_Formal_Packages): A formal package whose + actual part is (others => <>) os identical to a formal package + with an actual part written as (<>). + +2015-10-23 Arnaud Charlet + + * a-reatim.adb ("/"): For Time_Span division convert the operands + to integers and then use integer division, which conforms to + the rounding required by Ada RM. + 2015-10-23 Ed Schonberg * sem_ch6.adb (Check_Missing_Return): Do not report a missing diff --git a/gcc/ada/a-reatim.adb b/gcc/ada/a-reatim.adb index 4bac97b889b..83ff25bb5ed 100644 --- a/gcc/ada/a-reatim.adb +++ b/gcc/ada/a-reatim.adb @@ -31,6 +31,7 @@ ------------------------------------------------------------------------------ with System.Tasking; +with Unchecked_Conversion; package body Ada.Real_Time with SPARK_Mode => Off @@ -117,8 +118,20 @@ is function "/" (Left, Right : Time_Span) return Integer is pragma Unsuppress (Overflow_Check); pragma Unsuppress (Division_Check); + + -- RM D.8 (27) specifies the effects of operators on Time_Span, and + -- rounding of the division operator in particular, to be the same as + -- effects on integer types. To get the correct rounding we first + -- convert Time_Span to its root type Duration, which is represented as + -- an 64-bit signed integer, and then use integer division. + + type Duration_Rep is range -(2 ** 63) .. +((2 ** 63 - 1)); + + function To_Integer is + new Unchecked_Conversion (Duration, Duration_Rep); begin - return Integer (Duration (Left) / Duration (Right)); + return Integer + (To_Integer (Duration (Left)) / To_Integer (Duration (Right))); end "/"; function "/" (Left : Time_Span; Right : Integer) return Time_Span is diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index eb25c9b332b..5df60377ea0 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -9598,7 +9598,7 @@ package body Exp_Ch6 is begin Actuals := Parameter_Associations (N); - -- Original function amy have been parameterless. + -- Original function may have been parameterless if No (Actuals) then Actuals := New_List; diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 53f1cad6110..e7d279ae7aa 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -2590,6 +2590,7 @@ package body Sem_Ch12 is or else Nkind (First (Generic_Associations (N))) = N_Others_Choice then Associations := False; + Set_Box_Present (N); end if; -- If there are no generic associations, the generic parameters appear @@ -6127,8 +6128,9 @@ package body Sem_Ch12 is --------------------------- procedure Check_Formal_Packages (P_Id : Entity_Id) is - E : Entity_Id; - Formal_P : Entity_Id; + E : Entity_Id; + Formal_P : Entity_Id; + Formal_Decl : Node_Id; begin -- Iterate through the declarations in the instance, looking for package @@ -6146,15 +6148,35 @@ package body Sem_Ch12 is elsif Nkind (Parent (E)) /= N_Package_Renaming_Declaration then null; - elsif not Box_Present (Parent (Associated_Formal_Package (E))) then - Formal_P := Next_Entity (E); - Check_Formal_Package_Instance (Formal_P, E); + else + Formal_Decl := Parent (Associated_Formal_Package (E)); + + -- Nothing to check if the formal has a box or an + -- others_clause (necessarily with a box). + + if Box_Present (Formal_Decl) then + null; + + elsif Nkind (First (Generic_Associations (Formal_Decl))) = + N_Others_Choice + then + -- The internal validating package was generated but + -- formal and instance are known to be compatible.. + + Formal_P := Next_Entity (E); + Remove (Unit_Declaration_Node (Formal_P)); - -- After checking, remove the internal validating package. It - -- is only needed for semantic checks, and as it may contain - -- generic formal declarations it should not reach gigi. + else + Formal_P := Next_Entity (E); + Check_Formal_Package_Instance (Formal_P, E); - Remove (Unit_Declaration_Node (Formal_P)); + -- After checking, remove the internal validating package. + -- It is only needed for semantic checks, and as it may + -- contain generic formal declarations it should not + -- reach gigi. + + Remove (Unit_Declaration_Node (Formal_P)); + end if; end if; end if;