From: Ronan Desplanques <desplanq...@adacore.com>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/fname.adb | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/gcc/ada/fname.adb b/gcc/ada/fname.adb
index 165411cf6ec..7c5572a8c03 100644
--- a/gcc/ada/fname.adb
+++ b/gcc/ada/fname.adb
@@ -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;
-- 
2.43.0

Reply via email to