aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorViljar Indus <indus@adacore.com>2024-03-27 12:09:43 +0200
committerMarc Poulhiès <poulhies@adacore.com>2024-06-13 15:30:32 +0200
commit73dbf51a8bc514f22670e2d5c82d5fdc5252118d (patch)
treea63e6b409f5b13b881108e3990df2eba154b4f7c /gcc
parent047135cfed8c4c3950bda207dc87d33ca4c154ea (diff)
downloadgcc-73dbf51a8bc514f22670e2d5c82d5fdc5252118d.zip
gcc-73dbf51a8bc514f22670e2d5c82d5fdc5252118d.tar.gz
gcc-73dbf51a8bc514f22670e2d5c82d5fdc5252118d.tar.bz2
ada: Simplify code in Cannot_Inline
gcc/ada/ * inline.adb (Cannot_Inline): Simplify string handling logic.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/inline.adb20
1 files changed, 10 insertions, 10 deletions
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb
index 8e98fb5..f5c5426 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;