From: Ed Schonberg Date: Wed, 25 Mar 2020 16:49:13 +0000 (-0400) Subject: [Ada] Compiler locks up with -gnatX and formal subprogram with aspects X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=834bb57ac5a28e740b8f6e55059a102b99380176;p=gcc.git [Ada] Compiler locks up with -gnatX and formal subprogram with aspects 2020-06-12 Ed Schonberg gcc/ada/ * sem_ch12.adb (Find_Matching_Actual): Add guard on search loops to detect a compilation error when using a compiler built without assertions. (Instantiate_Formal_Subprogram): Create a new subprogram name for the actual only if formal has contract aspects and expansion is enabled. --- diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 26987d5d7a3..8972bedae82 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -10403,7 +10403,9 @@ package body Sem_Ch12 is => Formal_Ent := Defining_Identifier (F); - while Chars (Act) /= Chars (Formal_Ent) loop + while Present (Act) + and then Chars (Act) /= Chars (Formal_Ent) + loop Next_Entity (Act); end loop; @@ -10414,7 +10416,9 @@ package body Sem_Ch12 is => Formal_Ent := Defining_Entity (F); - while Chars (Act) /= Chars (Formal_Ent) loop + while Present (Act) + and then Chars (Act) /= Chars (Formal_Ent) + loop Next_Entity (Act); end loop; @@ -10934,13 +10938,16 @@ package body Sem_Ch12 is -- Create new entity for the actual (New_Copy_Tree does not), and -- indicate that it is an actual. - -- If the actual is not an entity and the formal includes aspect - -- specifications for contracts, we create an internal name for - -- the renaming declaration. The constructed wrapper contains a - -- call to the entity in the renaming. + -- If the actual is not an entity (i.e. an attribute reference) + -- and the formal includes aspect specifications for contracts, + -- we create an internal name for the renaming declaration. The + -- constructed wrapper contains a call to the entity in the renaming. + -- This is an expansion activity, as is the wrapper creation. if Ada_Version >= Ada_2020 - and then Present (Aspect_Specifications (Analyzed_Formal)) + and then Has_Contracts (Analyzed_Formal) + and then not Is_Entity_Name (Actual) + and then Expander_Active then New_Subp := Make_Temporary (Sloc (Actual), 'S'); Set_Defining_Unit_Name (New_Spec, New_Subp);