https://gcc.gnu.org/g:73dbf51a8bc514f22670e2d5c82d5fdc5252118d
commit r15-1276-g73dbf51a8bc514f22670e2d5c82d5fdc5252118d Author: Viljar Indus <in...@adacore.com> Date: Wed Mar 27 12:09:43 2024 +0200 ada: Simplify code in Cannot_Inline gcc/ada/ * inline.adb (Cannot_Inline): Simplify string handling logic. Diff: --- gcc/ada/inline.adb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index 8e98fb5ad101..f5c542635159 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -2110,6 +2110,11 @@ package body Inline is Is_Serious : Boolean := False; Suppress_Info : Boolean := False) is + Inline_Prefix : constant String := "cannot inline"; + + function Starts_With (S, Prefix : String) return Boolean is + (S (S'First .. S'First + Prefix'Length - 1) = Prefix); + begin -- In GNATprove mode, inlining is the technical means by which the -- higher-level goal of contextual analysis is reached, so issue @@ -2117,20 +2122,15 @@ package body Inline is -- subprogram, rather than failure to inline it. if GNATprove_Mode - and then Msg (Msg'First .. Msg'First + 12) = "cannot inline" + and then Starts_With (Msg, Inline_Prefix) then declare - Len1 : constant Positive := - String'("cannot inline")'Length; - Len2 : constant Positive := - String'("info: no contextual analysis of")'Length; - - New_Msg : String (1 .. Msg'Length + Len2 - Len1); + Msg_Txt : constant String := + Msg (Msg'First + Inline_Prefix'Length .. Msg'Last); + New_Msg : constant String := + "info: no contextual analysis of" & Msg_Txt; begin - New_Msg (1 .. Len2) := "info: no contextual analysis of"; - New_Msg (Len2 + 1 .. Msg'Length + Len2 - Len1) := - Msg (Msg'First + Len1 .. Msg'Last); Cannot_Inline (New_Msg, N, Subp, Is_Serious, Suppress_Info); return; end;