]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix reproducer generation
authorRonan Desplanques <desplanques@adacore.com>
Mon, 20 Jan 2025 15:14:21 +0000 (16:14 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 5 Jun 2025 08:18:36 +0000 (10:18 +0200)
This patch fixes reproducer generation in the case of crashes in the
back end in the presence of preprocessing dependencies.

gcc/ada/ChangeLog:

* generate_minimal_reproducer.adb (Generate_Minimal_Reproducer): Fix
handling of preprocessing dependencies.

gcc/ada/generate_minimal_reproducer.adb

index 2378f60c4729d65128bdda5a52afcc3a21c6bf50..5a5ae16193e5efb61cb9c7c040ccfc1353e8a4a1 100644 (file)
@@ -140,28 +140,30 @@ begin
       end if;
 
       for J in Main_Unit .. Lib.Last_Unit loop
-         declare
-            Path : File_Name_Type :=
-              Fmap.Mapped_Path_Name (Lib.Unit_File_Name (J));
-
-            Unit_Name : constant Unit_Name_Type :=
-              (if J = Main_Unit then Main_Unit_Name else Lib.Unit_Name (J));
-
-            Default_File_Name : constant String :=
-              Fname.UF.Get_Default_File_Name (Unit_Name);
-
-            File_Copy_Path : constant String :=
-              Src_Dir_Path & Directory_Separator & Default_File_Name;
-
-            --  We may have synthesized units for child subprograms without
-            --  spec files. We need to filter out those units because we would
-            --  create bogus spec files that break compilation if we didn't.
-            Is_Synthetic_Subprogram_Spec : constant Boolean :=
-              not Comes_From_Source (Lib.Cunit (J));
-         begin
-            if not Lib.Is_Internal_Unit (J)
-              and then not Is_Synthetic_Subprogram_Spec
-            then
+         --  We skip library units that fall under one of the following cases:
+         --  - Internal library units.
+         --  - Units that were synthesized for child subprograms without spec
+         --    files.
+         --  - Dummy entries that Add_Preprocessing_Dependency puts in
+         --    Lib.Units.
+         --  Those cases correspond to the conjuncts in the condition below.
+         if not Lib.Is_Internal_Unit (J)
+           and then Comes_From_Source (Lib.Cunit (J))
+           and then Lib.Unit_Name (J) /= No_Unit_Name
+         then
+            declare
+               Path : File_Name_Type :=
+                 Fmap.Mapped_Path_Name (Lib.Unit_File_Name (J));
+
+               Unit_Name : constant Unit_Name_Type :=
+                 (if J = Main_Unit then Main_Unit_Name else Lib.Unit_Name (J));
+
+               Default_File_Name : constant String :=
+                 Fname.UF.Get_Default_File_Name (Unit_Name);
+
+               File_Copy_Path : constant String :=
+                 Src_Dir_Path & Directory_Separator & Default_File_Name;
+            begin
                --  Mapped_Path_Name might have returned No_File. This has been
                --  observed for files with a Source_File_Name pragma.
                if Path = No_File then
@@ -178,8 +180,8 @@ begin
 
                   pragma Assert (Success);
                end;
-            end if;
-         end;
+            end;
+         end if;
       end loop;
    end Create_Semantic_Closure_Project;