[gcc r15-1143] ada: Remove incorrect assertion in run-time

Marc Poulhi?s dkm@gcc.gnu.org
Mon Jun 10 09:08:04 GMT 2024


https://gcc.gnu.org/g:e12e69b1f5b0e966200b6c9b9bf73e624d62add7

commit r15-1143-ge12e69b1f5b0e966200b6c9b9bf73e624d62add7
Author: Ronan Desplanques <desplanques@adacore.com>
Date:   Fri Apr 12 15:25:22 2024 +0200

    ada: Remove incorrect assertion in run-time
    
    There is a special case of file paths on Windows that are absolute
    but don't start with a drive letter: UNC paths. This patch removes
    an assertion in System.OS_Lib.Normalize_Pathname that failed to take
    this case into account. It also renames a local subprogram of
    Normalize_Pathname to make its purpose clearer.
    
    gcc/ada/
    
            * libgnat/s-os_lib.adb (Normalize_Pathname): Remove incorrect
            assert statement.
            (Missed_Drive_Letter): Rename into...
            (Drive_Letter_Omitted): This.

Diff:
---
 gcc/ada/libgnat/s-os_lib.adb | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/ada/libgnat/s-os_lib.adb
index 20e109aaa0b..dd2156e1dcb 100644
--- a/gcc/ada/libgnat/s-os_lib.adb
+++ b/gcc/ada/libgnat/s-os_lib.adb
@@ -2089,8 +2089,10 @@ package body System.OS_Lib is
       --  Returns True only if the Name is including a drive
       --  letter at start.
 
-      function Missed_Drive_Letter (Name : String) return Boolean;
-      --  Missed drive letter at start of the normalized pathname
+      function Drive_Letter_Omitted (Name : String) return Boolean;
+      --  Name must be an absolute path. Returns True if and only if
+      --  Name doesn't start with a drive letter and Name is not a
+      --  UNC path.
 
       -------------------
       -- Is_With_Drive --
@@ -2104,11 +2106,11 @@ package body System.OS_Lib is
                      or else Name (Name'First) in 'A' .. 'Z');
       end Is_With_Drive;
 
-      -------------------------
-      -- Missed_Drive_Letter --
-      -------------------------
+      --------------------------
+      -- Drive_Letter_Omitted --
+      --------------------------
 
-      function Missed_Drive_Letter (Name : String) return Boolean is
+      function Drive_Letter_Omitted (Name : String) return Boolean is
       begin
          return On_Windows
            and then not Is_With_Drive (Name)
@@ -2117,7 +2119,7 @@ package body System.OS_Lib is
                              /= Directory_Separator
                      or else Name (Name'First + 1)
                              /= Directory_Separator);
-      end Missed_Drive_Letter;
+      end Drive_Letter_Omitted;
 
       -----------------
       -- Final_Value --
@@ -2174,7 +2176,7 @@ package body System.OS_Lib is
 
          elsif Directory = ""
            or else not Is_Absolute_Path (Directory)
-           or else Missed_Drive_Letter (Directory)
+           or else Drive_Letter_Omitted (Directory)
          then
             --  Directory name not given or it is not absolute or without drive
             --  letter on Windows, get current directory.
@@ -2251,7 +2253,7 @@ package body System.OS_Lib is
       end if;
 
       if Is_Absolute_Path (Name) then
-         if Missed_Drive_Letter (Name) then
+         if Drive_Letter_Omitted (Name) then
             Fill_Directory (Drive_Only => True);
 
             --  Take only drive letter part with colon
@@ -2286,8 +2288,6 @@ package body System.OS_Lib is
 
          --  Ensure drive letter is upper-case
 
-         pragma Assert (Path_Buffer (2) = ':');
-
          if Path_Buffer (1) in 'a' .. 'z' then
             System.Case_Util.To_Upper (Path_Buffer (1 .. 1));
          end if;


More information about the Gcc-cvs mailing list