diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0b04cd741741..2f3bd34d8b9d 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,46 @@ +2014-07-30 Ed Schonberg + + * inline.adb (Expand_Inlined_Call): Use a renaming declaration + to capture the value of actuals of a limited type rather than + an object declaration, to prevent spurious errors when analyzing + the inlined body. + +2014-07-30 Ed Schonberg + + * sem_ch4.adb (Analyze_Type_Conversion): Treat an inlined body + as an instance, and inhibit semantic checks on already analyzed + code to prevent spurious errors. + +2014-07-30 Arnaud Charlet + + * a-exctra.ads ("="): New function, to restore compatibility. + +2014-07-30 Pascal Obry + + * adaint.c (__gnat_to_os_time): Set isdst to -1 for the mktime + routine to use the OS dst setting. + +2014-07-30 Pat Rogers + + * gnat_ugn.texi: Minor correction to description of -gnatw.K. + +2014-07-30 Ed Schonberg + + * sem_util.adb (Wrong_Type): Disable some checks equally within + instances and within inlined bodies, to suppress spurious type + errors on already analyzed code. + * sem_aggr.adb (Check_Expr_OK_In_Limited_Aggregate): Expression + is legal in an inlined body, juts as it is in an instance body. + +2014-07-30 Ed Schonberg + + * sem_res.adb (Resolve_Unchecked_Conversion): Within an inlined + body the operand of an unchecked conversion may be a literal, in + which case its type is the target type of the conversion. This + is in contrast to conversions in other contexts, where the + operand cannot be a literal and must be resolvable independent + of the context. + 2014-07-30 Pierre-Marie Derodat * gcc-interface/decl.c (gnat_to_gnu_entity) : Create a diff --git a/gcc/ada/a-exctra.ads b/gcc/ada/a-exctra.ads index af1d59b96582..664bd75221f1 100644 --- a/gcc/ada/a-exctra.ads +++ b/gcc/ada/a-exctra.ads @@ -52,6 +52,9 @@ package Ada.Exceptions.Traceback is -- occurrence, and returns it formatted in the manner required for -- processing in GNAT.Traceback. See g-traceb.ads for further details. + function "=" (A, B : Tracebacks_Array) return Boolean renames STBE."="; + -- Make "=" operator visible directly + function Get_PC (TBE : STBE.Traceback_Entry) return Code_Loc renames STBE.PC_For; -- Returns the code address held by a given traceback entry, typically the diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index a84f4a5f474f..96dedfeb447d 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -516,7 +516,7 @@ __gnat_to_os_time (OS_Time *p_time, int year, int month, int day, v.tm_hour = hours; v.tm_min = mins; v.tm_sec = secs; - v.tm_isdst = 0; + v.tm_isdst = -1; /* returns -1 of failing, this is s-os_lib Invalid_Time */ diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index af2c27565101..cc1f7fd47b16 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -5415,7 +5415,7 @@ work as expected. Names of discriminants and components in records are not included in this check. @item -gnatw.K -@emph{Suppress warnings on variables that could be constants.} +@emph{Suppress warnings on redefinition of names in standard.} @cindex @option{-gnatwK} (@command{gcc}) This switch activates warnings for declarations that declare a name that is defined in package Standard. diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index b9d0d8e27229..86704dc052a4 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -3834,8 +3834,12 @@ package body Inline is -- call will pass the parameter by reference, and thus the inlined -- code will have the same semantics. + -- Finally, we need a renaming declaration in the case of limited + -- types for which initialization cannot be by copy either. + if Ekind (F) = E_In_Parameter and then not Is_By_Reference_Type (Etype (A)) + and then not Is_Limited_Type (Etype (A)) and then (not Is_Array_Type (Etype (A)) or else not Is_Object_Reference (A) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 157b20241490..3e71ebe0de52 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -111,6 +111,7 @@ package body Sem_Aggr is -- Check that Expr is either not limited or else is one of the cases of -- expressions allowed for a limited component association (namely, an -- aggregate, function call, or <> notation). Report error for violations. + -- Expression is also OK in an instance or inlining context. procedure Check_Qualified_Aggregate (Level : Nat; Expr : Node_Id); -- Given aggregate Expr, check that sub-aggregates of Expr that are nested @@ -687,10 +688,13 @@ package body Sem_Aggr is begin if Is_Limited_Type (Etype (Expr)) and then Comes_From_Source (Expr) - and then not In_Instance_Body then - if not OK_For_Limited_Init (Etype (Expr), Expr) then - Error_Msg_N ("initialization not allowed for limited types", Expr); + if In_Instance_Body or else In_Inlined_Body then + null; + + elsif not OK_For_Limited_Init (Etype (Expr), Expr) then + Error_Msg_N + ("initialization not allowed for limited types", Expr); Explain_Limited_Type (Etype (Expr), Expr); end if; end if; diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index f7d6aa895b64..b78b06a05e04 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -4934,9 +4934,9 @@ package body Sem_Ch4 is -- error message. Conversely, constant-folding in the generic may -- transform the argument of a conversion into a string literal, which -- is legal. Therefore the following tests are not performed in an - -- instance. + -- instance. The same applies to an inlined body. - elsif In_Instance then + elsif In_Instance or In_Inlined_Body then return; elsif Nkind (Expr) = N_Null then diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 332bc6090c76..52b717e0593d 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -10680,6 +10680,20 @@ package body Sem_Res is -- Resolve operand using its own type Resolve (Operand, Opnd_Type); + + -- In an inlined context, the unchecked conversion may be applied + -- to a literal, in which case its type is the type of the context. + -- (In other contexts conversions cannot apply to literals). + + if In_Inlined_Body + and then + (Opnd_Type = Any_Character or else + Opnd_Type = Any_Integer or else + Opnd_Type = Any_Real) + then + Set_Etype (Operand, Typ); + end if; + Analyze_Dimension (N); Eval_Unchecked_Conversion (N); end Resolve_Unchecked_Type_Conversion; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 916942a6bd06..5aa63a955859 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -17254,7 +17254,11 @@ package body Sem_Util is -- Similarly, full and partial views may be incorrect in the instance. -- There is no simple way to insure that it is consistent ??? - elsif In_Instance then + -- A similar view discrepancy can happen in an inlined body, for the + -- same reason: inserted body may be outside of the original package + -- and only partial views are visible at the point of insertion. + + elsif In_Instance or else In_Inlined_Body then if Etype (Etype (Expr)) = Etype (Expected_Type) and then (Has_Private_Declaration (Expected_Type) @@ -17262,6 +17266,17 @@ package body Sem_Util is and then No (Parent (Expected_Type)) then return; + + elsif Nkind (Parent (Expr)) = N_Qualified_Expression + and then Entity (Subtype_Mark (Parent (Expr))) = Expected_Type + then + return; + + elsif Is_Private_Type (Expected_Type) + and then Present (Full_View (Expected_Type)) + and then Covers (Full_View (Expected_Type), Etype (Expr)) + then + return; end if; end if;