From: Pierre-Marie de Rodat Date: Mon, 9 Oct 2017 20:19:13 +0000 (+0000) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f192ca5eea6a1b12e0cdf1e4342faa52744c5a25;p=gcc.git [multiple changes] 2017-10-09 Hristian Kirtchev * sem_elab.adb (Is_Suitable_Access): This scenario is now only relevant in the static model. (Is_Suitable_Variable_Assignment): This scenario is now only relevant in the static model. (Is_Suitable_Variable_Reference): This scenario is now only relevant in the static model. 2017-10-09 Ed Schonberg * sem_ch3.adb (Analyze_Declarations): In ASIS mode, resolve aspect expressions when the enclosing scope is a subprogram body and the next declaration is a body that freezes entities previously declared in the scope. 2017-10-09 Justin Squirek * sem_ch8.adb (Analyze_Use_Package): Remove checking of mixture between ghost packages and living packages in use clauses. (Use_One_Type, Note_Redundant_Use): Correct warning messages 2017-10-09 Justin Squirek * osint.ads: Document new parameter FD for Read_Source_File. From-SVN: r253564 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 31b6dc0e3da..20d60c38bf2 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,29 @@ +2017-10-09 Hristian Kirtchev + + * sem_elab.adb (Is_Suitable_Access): This scenario is now only relevant + in the static model. + (Is_Suitable_Variable_Assignment): This scenario is now only relevant + in the static model. + (Is_Suitable_Variable_Reference): This scenario is now only relevant in + the static model. + +2017-10-09 Ed Schonberg + + * sem_ch3.adb (Analyze_Declarations): In ASIS mode, resolve aspect + expressions when the enclosing scope is a subprogram body and the next + declaration is a body that freezes entities previously declared in the + scope. + +2017-10-09 Justin Squirek + + * sem_ch8.adb (Analyze_Use_Package): Remove checking of mixture between + ghost packages and living packages in use clauses. + (Use_One_Type, Note_Redundant_Use): Correct warning messages + +2017-10-09 Justin Squirek + + * osint.ads: Document new parameter FD for Read_Source_File. + 2017-10-09 Ed Schonberg * exp_util.adb (Make_Predicate_Call): If the type of the expression to diff --git a/gcc/ada/osint.ads b/gcc/ada/osint.ads index 4d6a4a4d8cd..b8edeec2b58 100644 --- a/gcc/ada/osint.ads +++ b/gcc/ada/osint.ads @@ -405,7 +405,8 @@ package Osint is T : File_Type := Source); -- Allocates a Source_Buffer of appropriate length and then reads the -- entire contents of the source file N into the buffer. The address of - -- the allocated buffer is returned in Src. + -- the allocated buffer is returned in Src. FD is used for extended error + -- information in the case the read fails. -- -- Each line of text is terminated by one of the sequences: -- @@ -427,7 +428,11 @@ package Osint is -- failure to find the file is a fatal error, an error message is output, -- and program execution is terminated. Otherwise (for the case of a -- subsidiary source loaded directly or indirectly using with), a file - -- not found condition causes null to be set as the result value. + -- not found condition causes null to be set as the result value and a + -- value of No_Source_File (0) to be set as the FD value. In the related + -- case of a file with no read permissions the result is the same except FD + -- is set to No_Access_To_Source_File (-1). Upon success FD is set to a + -- positive Source_File_Index. -- -- Note that the name passed to this function is the simple file name, -- without any directory information. The implementation is responsible diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 7f54daaee92..2e4134cc3f5 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -2231,7 +2231,8 @@ package body Sem_Ch3 is procedure Resolve_Aspects; -- Utility to resolve the expressions of aspects at the end of a list of - -- declarations. + -- declarations, or before a declaration that freezes previous entities, + -- such as in a subprogram body. function Uses_Unseen_Priv (Pkg : Entity_Id) return Boolean; -- Check if a nested package has entities within it that rely on library @@ -2789,6 +2790,12 @@ package body Sem_Ch3 is if Nkind (Next_Decl) = N_Subprogram_Body then Handle_Late_Controlled_Primitive (Next_Decl); end if; + + else + -- In ASIS mode, if the next declaration is a body, complete + -- the analysis of declarations so far. + + Resolve_Aspects; end if; Adjust_Decl; diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index d0c417ba0f5..26714c87c87 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -3836,25 +3836,6 @@ package body Sem_Ch8 is end if; end if; end if; - - -- Detect a mixture of Ghost packages and living packages within the - -- same use_package_clause. Ideally one would split a use_package_clause - -- with multiple names into multiple use_package_clauses with a single - -- name, however clients of the front end would have to adapt to this - -- change. - - if Present (Ghost_Id) and then Present (Living_Id) then - Error_Msg_N - ("use clause cannot mention ghost and non-ghost ghost units", N); - - Error_Msg_Sloc := Sloc (Ghost_Id); - Error_Msg_NE ("\& # declared as ghost", N, Ghost_Id); - - Error_Msg_Sloc := Sloc (Living_Id); - Error_Msg_NE ("\& # declared as non-ghost", N, Living_Id); - end if; - - Mark_Ghost_Clause (N); end Analyze_Use_Package; ---------------------- @@ -9354,7 +9335,7 @@ package body Sem_Ch8 is Error_Msg_Sloc := Sloc (Prev_Use); Error_Msg_NE -- CODEFIX - ("& is already use-visible through previous use clause #??", + ("& is already use-visible through previous use_clause #??", Redundant, Pack_Name); end if; end Note_Redundant_Use; @@ -10001,7 +9982,7 @@ package body Sem_Ch8 is else Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " - & "use type clause??", Id, T); + & "use_type_clause??", Id, T); end if; end Use_Clause_Known; @@ -10011,7 +9992,7 @@ package body Sem_Ch8 is else Error_Msg_NE -- CODEFIX ("& is already use-visible through previous " - & "use type clause??", Id, T); + & "use_type_clause??", Id, T); end if; -- The package where T is declared is already used diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb index e1ef3f8c3fa..909a50090fc 100644 --- a/gcc/ada/sem_elab.adb +++ b/gcc/ada/sem_elab.adb @@ -4995,10 +4995,26 @@ package body Sem_Elab is Subp_Id : Entity_Id; begin - if Nkind (N) /= N_Attribute_Reference then + -- This scenario is relevant only when the static model is in effect + -- because it is graph-dependent and does not involve any run-time + -- checks. Allowing it in the dynamic model would create confusing + -- noise. + + if not Static_Elaboration_Checks then + return False; + + -- Nothing to do when switch -gnatd.U (ignore 'Access) is in effect + + elsif Debug_Flag_Dot_UU then return False; - -- Internally-generated attributes are assumed to be ABE safe + -- Nothing to do when the scenario is not an attribute reference + + elsif Nkind (N) /= N_Attribute_Reference then + return False; + + -- Nothing to do for internally-generated attributes because they are + -- assumed to be ABE safe. elsif not Comes_From_Source (N) then return False; @@ -5031,16 +5047,10 @@ package body Sem_Elab is return - -- This particular scenario is relevant only in the static model when - -- switch -gnatd.U (ignore 'Access) is not in effect. - - Static_Elaboration_Checks - and then not Debug_Flag_Dot_UU + -- The prefix must denote a source entry, operator, or subprogram + -- which is not imported. - -- The prefix must denote an entry, operator, or subprogram which is - -- not imported. - - and then Comes_From_Source (Subp_Id) + Comes_From_Source (Subp_Id) and then Is_Subprogram_Or_Entry (Subp_Id) and then not Is_Bodiless_Subprogram (Subp_Id) @@ -5109,10 +5119,21 @@ package body Sem_Elab is Var_Unit_Id : Entity_Id; begin - if Nkind (N) /= N_Assignment_Statement then + -- This scenario is relevant only when the static model is in effect + -- because it is graph-dependent and does not involve any run-time + -- checks. Allowing it in the dynamic model would create confusing + -- noise. + + if not Static_Elaboration_Checks then return False; - -- Internally-generated assigments are assumed to be ABE safe + -- Nothing to do when the scenario is not an assignment + + elsif Nkind (N) /= N_Assignment_Statement then + return False; + + -- Nothing to do for internally-generated assignments because they are + -- assumed to be ABE safe. elsif not Comes_From_Source (N) then return False; @@ -5161,10 +5182,10 @@ package body Sem_Elab is -- To qualify, the assignment must meet the following prerequisites: return - Comes_From_Source (Var_Id) - -- The variable must be susceptible to warnings + -- The variable must be a source entity and susceptible to warnings + Comes_From_Source (Var_Id) and then not Has_Warnings_Off (Var_Id) -- The variable must be declared in the spec of compilation unit U @@ -5232,14 +5253,23 @@ package body Sem_Elab is -- Start of processing for Is_Suitable_Variable_Reference begin + -- This scenario is relevant only when the static model is in effect + -- because it is graph-dependent and does not involve any run-time + -- checks. Allowing it in the dynamic model would create confusing + -- noise. + + if not Static_Elaboration_Checks then + return False; + -- Attributes and operator sumbols are not considered to be suitable -- references to variables even though they are part of predicate -- Is_Entity_Name. - if not Nkind_In (N, N_Expanded_Name, N_Identifier) then + elsif not Nkind_In (N, N_Expanded_Name, N_Identifier) then return False; - -- Internally generated references are assumed to be ABE safe + -- Nothing to do for internally-generated references because they are + -- assumed to be ABE safe. elsif not Comes_From_Source (N) then return False;