[Ada] Crash on expansion of BIP construct in -gnatf mode
authorJustin Squirek <squirek@adacore.com>
Tue, 15 Jun 2021 16:54:12 +0000 (12:54 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 9 Jul 2021 12:35:31 +0000 (12:35 +0000)
gcc/ada/

* exp_ch6.adb (Is_Build_In_Place_Function_Call): Add check to
verify the Selector_Name of Exp_Node has been analyzed before
obtaining its entity.

gcc/ada/exp_ch6.adb

index 1c56cb8..59704a4 100644 (file)
@@ -8275,6 +8275,15 @@ package body Exp_Ch6 is
       --  This may be a call to a protected function.
 
       elsif Nkind (Name (Exp_Node)) = N_Selected_Component then
+         --  The selector in question might not have been analyzed due to a
+         --  previous error, so analyze it here to output the appropriate
+         --  error message instead of crashing when attempting to fetch its
+         --  entity.
+
+         if not Analyzed (Selector_Name (Name (Exp_Node))) then
+            Analyze (Selector_Name (Name (Exp_Node)));
+         end if;
+
          Function_Id := Etype (Entity (Selector_Name (Name (Exp_Node))));
 
       else