[Ada] Don't crash on ghost packages when emitting CUDA symbols in ALI files
authorGhjuvan Lacambre <lacambre@adacore.com>
Mon, 14 Mar 2022 08:58:52 +0000 (09:58 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 16 May 2022 08:42:05 +0000 (08:42 +0000)
Before this commit, a GNAT compiled with assertions would crash when
attempting to emit CUDA symbols in ALI files for spark_mode/ghost
packages, whose content is a single null statement.

gcc/ada/

* lib-writ.adb (Output_CUDA_Symbols): Check for null packages.

gcc/ada/lib-writ.adb

index 556df9a..b525bba 100644 (file)
@@ -403,7 +403,9 @@ package body Lib.Writ is
          Kernel_Elm  : Elmt_Id;
          Kernel      : Entity_Id;
       begin
-         if not Enable_CUDA_Expansion then
+         if not Enable_CUDA_Expansion
+           or else Nkind (Unit_Id) = N_Null_Statement
+         then
             return;
          end if;
          Spec_Id := (if Nkind (Unit_Id) = N_Package_Body