[Ada] Crash in Walk_Library_Items on ghost units
authorArnaud Charlet <charlet@adacore.com>
Sat, 23 May 2020 18:50:10 +0000 (20:50 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 10 Jul 2020 09:16:15 +0000 (05:16 -0400)
gcc/ada/

* sem.adb (Walk_Library_Items): Fix handling of Ghost units.

gcc/ada/sem.adb

index b84df65..425dafa 100644 (file)
@@ -1848,12 +1848,16 @@ package body Sem is
                   if Withed_Unit /= Main_CU
                     and then not Done (Get_Cunit_Unit_Number (Withed_Unit))
                   then
+                     --  N_Null_Statement will happen in case of a ghost unit
+                     --  which gets rewritten.
+
                      if not Nkind_In
                               (Unit (Withed_Unit),
                                  N_Generic_Package_Declaration,
                                  N_Package_Body,
                                  N_Package_Renaming_Declaration,
-                                 N_Subprogram_Body)
+                                 N_Subprogram_Body,
+                                 N_Null_Statement)
                      then
                         Write_Unit_Name
                           (Unit_Name (Get_Cunit_Unit_Number (Withed_Unit)));