From: Arnaud Charlet Date: Tue, 25 Apr 2017 08:33:18 +0000 (+0200) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2bb988bb1cb15663ce9d01368d31d66161183b41;p=gcc.git [multiple changes] 2017-04-25 Hristian Kirtchev * sem_aggr.adb, inline.adb, einfo.adb, einfo.ads, scng.adb, sem_prag.adb: Minor reformatting. 2017-04-25 Bob Duff * sem_attr.adb (Type_Key): Add code in the recursive Compute_Type_Key to protect against fetching the source code for Standard, in case a component of the type is declared in Standard. There was already code to do this for the original type, but not for its components. From-SVN: r247147 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ee46f95f4d5..75733c1a823 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,16 @@ +2017-04-25 Hristian Kirtchev + + * sem_aggr.adb, inline.adb, einfo.adb, einfo.ads, scng.adb, + sem_prag.adb: Minor reformatting. + +2017-04-25 Bob Duff + + * sem_attr.adb (Type_Key): Add code in the + recursive Compute_Type_Key to protect against fetching the source + code for Standard, in case a component of the type is declared + in Standard. There was already code to do this for the original + type, but not for its components. + 2017-04-25 Javier Miranda * exp_ch3.adb (Build_Initialization_Call): Handle diff --git a/gcc/ada/einfo.adb b/gcc/ada/einfo.adb index e01abddecea..9f9a0a617bf 100644 --- a/gcc/ada/einfo.adb +++ b/gcc/ada/einfo.adb @@ -9262,8 +9262,8 @@ package body Einfo is end if; W ("Address_Taken", Flag104 (Id)); - W ("Body_Needed_For_SAL", Flag40 (Id)); W ("Body_Needed_For_Inlining", Flag299 (Id)); + W ("Body_Needed_For_SAL", Flag40 (Id)); W ("C_Pass_By_Copy", Flag125 (Id)); W ("Can_Never_Be_Null", Flag38 (Id)); W ("Checks_May_Be_Suppressed", Flag31 (Id)); diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index a08d5d26d21..f0080d550d3 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -6245,13 +6245,13 @@ package Einfo is -- Contract (Node34) -- SPARK_Pragma (Node40) -- SPARK_Aux_Pragma (Node41) - -- Delay_Subprogram_Descriptors (Flag50) -- Body_Needed_For_Inlining (Flag299) -- Body_Needed_For_SAL (Flag40) -- Contains_Ignored_Ghost_Code (Flag279) + -- Delay_Subprogram_Descriptors (Flag50) -- Discard_Names (Flag88) - -- Elaboration_Entity_Required (Flag174) -- Elaborate_Body_Desirable (Flag210) (non-generic case only) + -- Elaboration_Entity_Required (Flag174) -- From_Limited_With (Flag159) -- Has_All_Calls_Remote (Flag79) -- Has_Completion (Flag26) diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index c20a2df8369..a5d5ce1c511 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -751,11 +751,12 @@ package body Inline is if Present (Comp_Unit) and then Comp_Unit /= Cunit (Main_Unit) and then Body_Required (Comp_Unit) - and then (Nkind (Unit (Comp_Unit)) /= N_Package_Declaration - or else - (No (Corresponding_Body (Unit (Comp_Unit))) - and then Body_Needed_For_Inlining - (Defining_Entity (Unit (Comp_Unit))))) + and then + (Nkind (Unit (Comp_Unit)) /= N_Package_Declaration + or else + (No (Corresponding_Body (Unit (Comp_Unit))) + and then Body_Needed_For_Inlining + (Defining_Entity (Unit (Comp_Unit))))) then declare Bname : constant Unit_Name_Type := diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb index 9b417a3a4fa..3f1c3a9eb53 100644 --- a/gcc/ada/scng.adb +++ b/gcc/ada/scng.adb @@ -2056,14 +2056,14 @@ package body Scng is -- In Ada 2020, a target name (i.e. @) is a valid prefix of an -- attribute, and functions like a name. - if Prev_Token = Tok_Identifier - or else Prev_Token = Tok_Right_Paren - or else Prev_Token = Tok_All - or else Prev_Token = Tok_Delta - or else Prev_Token = Tok_Digits - or else Prev_Token = Tok_Project - or else Prev_Token = Tok_At_Sign - or else Prev_Token in Token_Class_Literal + if Prev_Token = Tok_All + or else Prev_Token = Tok_At_Sign + or else Prev_Token = Tok_Delta + or else Prev_Token = Tok_Digits + or else Prev_Token = Tok_Identifier + or else Prev_Token = Tok_Project + or else Prev_Token = Tok_Right_Paren + or else Prev_Token in Token_Class_Literal then Token := Tok_Apostrophe; diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 223a59fcab8..d18383525c3 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -1666,7 +1666,7 @@ package body Sem_Aggr is else Analyze (Choice); - -- Choice can be a subtype name, a range, or an expression. + -- Choice can be a subtype name, a range, or an expression if Is_Entity_Name (Choice) and then Is_Type (Entity (Choice)) diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index bb719d33010..40ee462906c 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -6256,6 +6256,21 @@ package body Sem_Attr is return; end if; + -- If the type is declared in Standard, there is no source, so + -- just use its name. + + if Scope (T) = Standard_Standard then + declare + Name : constant String := Get_Name_String (Chars (T)); + begin + for J in Name'Range loop + System.CRC32.Update (CRC, Name (J)); + end loop; + end; + + return; + end if; + Sloc_Range (Enclosing_Declaration (T), P_Min, P_Max); SFI := Get_Source_File_Index (P_Min); Buffer := Source_Text (SFI); @@ -6318,25 +6333,21 @@ package body Sem_Attr is Store_String_Char (Get_String_Char (Full_Name, Pos (J))); end loop; - -- For standard types return the name of the type, as there is no - -- explicit source declaration to use. Otherwise compute CRC and - -- convert it to string one character at a time, so as not to use - -- Image within the compiler. + -- Compute CRC and convert it to string one character at a time, so + -- as not to use Image within the compiler. - if Scope (Entity (P)) /= Standard_Standard then - Initialize (CRC); - Compute_Type_Key (Entity (P)); - - if not Is_Frozen (Entity (P)) then - Error_Msg_N ("premature usage of Type_Key?", N); - end if; + Initialize (CRC); + Compute_Type_Key (Entity (P)); - while CRC > 0 loop - Store_String_Char (Character'Val (48 + (CRC rem 10))); - CRC := CRC / 10; - end loop; + if not Is_Frozen (Entity (P)) then + Error_Msg_N ("premature usage of Type_Key?", N); end if; + while CRC > 0 loop + Store_String_Char (Character'Val (48 + (CRC rem 10))); + CRC := CRC / 10; + end loop; + Rewrite (N, Make_String_Literal (Loc, End_String)); Analyze_And_Resolve (N, Standard_String); end Type_Key; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index e9c94198675..35e1b88a157 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -9118,8 +9118,8 @@ package body Sem_Prag is -- body. (this may be further refined). if not In_Instance - and then Nkind (Unit (Cunit (Current_Sem_Unit))) - = N_Package_Declaration + and then Nkind (Unit (Cunit (Current_Sem_Unit))) = + N_Package_Declaration then Set_Body_Needed_For_Inlining (Cunit_Entity (Current_Sem_Unit)); end if;