From: Ronan Desplanques Date: Mon, 3 Feb 2025 13:22:22 +0000 (+0100) Subject: ada: Fix SFN_Patterns documentation comment X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a419accb7741c317cede9466c369666d2ee2462;p=thirdparty%2Fgcc.git ada: Fix SFN_Patterns documentation comment The documentation comment under SFN_Patterns was misleading. This patch fixes it and also fixes Get_Default_File_Name which assumed the comment was correct. gcc/ada/ChangeLog: * fname-uf.adb: Fix documentation comment. (Get_Default_File_Name): Fix indices of default patterns. --- diff --git a/gcc/ada/fname-uf.adb b/gcc/ada/fname-uf.adb index 39a09c4ce13..ec22ad7a3d2 100644 --- a/gcc/ada/fname-uf.adb +++ b/gcc/ada/fname-uf.adb @@ -90,8 +90,9 @@ package body Fname.UF is Table_Initial => 10, Table_Increment => 100, Table_Name => "SFN_Patterns"); - -- Table recording calls to Set_File_Name_Pattern. Note that the first two - -- entries are set to represent the standard GNAT rules for file naming. + -- Table recording calls to Set_File_Name_Pattern. Note that the last two + -- entries are set to represent the standard GNAT rules for file naming; + -- that invariant is maintained by Set_File_Name_Pattern. procedure Instantiate_SFN_Pattern (Pattern : SFN_Pattern_Entry; @@ -178,6 +179,8 @@ package body Fname.UF is --------------------------- function Get_Default_File_Name (Uname : Unit_Name_Type) return String is + L : constant Int := SFN_Patterns.Last; + Buf : Bounded_String; Pattern : SFN_Pattern_Entry; @@ -185,10 +188,10 @@ package body Fname.UF is Get_Unit_Name_String (Buf, Uname, False); if Is_Spec_Name (Uname) then - Pattern := SFN_Patterns.Table (1); + Pattern := SFN_Patterns.Table (L - 1); else pragma Assert (Is_Body_Name (Uname)); - Pattern := SFN_Patterns.Table (2); + Pattern := SFN_Patterns.Table (L); end if; Instantiate_SFN_Pattern (Pattern, Buf);