From 5f74065e26a7a795d480884f352d0aeb69b8f436 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Sat, 23 May 2020 20:50:10 +0200 Subject: [PATCH] [Ada] Crash in Walk_Library_Items on ghost units gcc/ada/ * sem.adb (Walk_Library_Items): Fix handling of Ghost units. --- gcc/ada/sem.adb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb index b84df652aa5..425dafa55d3 100644 --- a/gcc/ada/sem.adb +++ b/gcc/ada/sem.adb @@ -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))); -- 2.30.2