]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Tweak Is_Predefined_File_Name
authorRonan Desplanques <desplanques@adacore.com>
Thu, 14 Nov 2024 16:11:03 +0000 (17:11 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 12 Dec 2024 09:57:55 +0000 (10:57 +0100)
This patch slightly widens the set of filenames that the compiler
considers predefined. That makes it possible to build the GNAT runtime
using only the file mapping facilities of the compiler, without having
to rename files.

gcc/ada/ChangeLog:

* fname.adb (Is_Predefined_File_Name): Tweak test.

gcc/ada/fname.adb

index 165411cf6ecf31764745da7425e6f11047365635..7c5572a8c03dc76f12edbc26d0b9b19a7f1ba9da 100644 (file)
@@ -141,6 +141,8 @@ package body Fname is
       if Fname'Length > 12
         and then Fname (Fname'First .. Fname'First + 1) /= "i-"
         and then Fname (Fname'First .. Fname'First + 1) /= "s-"
+        and then not Has_Prefix (Fname, "system-")
+        and then not Has_Prefix (Fname, "interfac__")
       then
          return False;
       end if;
@@ -151,23 +153,24 @@ package body Fname is
 
       --  Definitely predefined if prefix is a- i- or s-
 
-      if Fname'Length >= 2 then
-         declare
-            S : String renames Fname (Fname'First .. Fname'First + 1);
-         begin
-            if S = "a-" or else S = "i-" or else S = "s-" then
-               return True;
-            end if;
-         end;
-      end if;
+      pragma Assert (Fname'Length >= 2);
+      declare
+         S : String renames Fname (Fname'First .. Fname'First + 1);
+      begin
+         if S = "a-" or else S = "i-" or else S = "s-" then
+            return True;
+         end if;
+      end;
 
       --  We include the "." in the prefixes below, so we don't match (e.g.)
       --  adamant.ads. So the first line matches "ada.ads", "ada.adb", and
       --  "ada.ali". But that's not necessary if they have 8 characters.
 
       if Has_Prefix (Fname, "ada.")             --  Ada
-        or else Has_Prefix (Fname, "interfac")  --  Interfaces
+        or else Fname = "interfac.ads"
+        or else Has_Prefix (Fname, "interfac__")
         or else Has_Prefix (Fname, "system.a")  --  System
+        or else Has_Prefix (Fname, "system-")   --  System with platform suffix
       then
          return True;
       end if;