I have a project that has some problems with inlining some lines. I liked to know the reason and added an issue that FPC can report the issue. As
written by the developers, FPC already says the reason, but Lazarus does not show it.
program InlineHint;
uses unit1;
function Test1(A: PChar): PChar; inline;
begin
Result := A + 1;
end;
var
S: String;
P: PChar;
begin
S := 'Test';
P := Pointer(S); //Inlined
P := Test1(P);
P := Test1(Pointer(S)); //Not inlined
end.
When compiled by Lazarus, there is only a message about it can not inline the code, like the attached screenshot.
I tried to compile directly with FPC, and here is the result:
ppcx64 -l -Mobjfpc -B -Sh -vhd InlineHint.lpr
Found source file name "InlineHint.lpr"
Free Pascal Compiler version 3.3.1-r47323 [2020/11/05] for x86_64
Copyright (c) 1993-2020 by Florian Klaempfl and others
Compiler OS: Win64 for x64
Target OS: Win64 for x64
Compiling InlineHint.lpr
Compiling Unit1.pas
Unit1.pas(3,2) Handling switch "$MODE"
Unit1.pas(3,16) Handling switch "$H+"
Unit1.pas(13,1) procedure/function Test2(const PChar):^Char;
Unit1.pas(14,13) Note: Call to subroutine "function Test1(const A:PChar):^Char;" marked as inline is not inlined
Unit1.pas(18,1) procedure/function Test1(const PChar):^Char;
InlineHint.lpr(6,3) procedure/function Test1(PChar):^Char;
InlineHint.lpr(17,8) Not inlining "Test1", invocation parameter contains an unsafe/unsupported construct
InlineHint.lpr(17,8) Note: Call to subroutine "function Test1(A:PChar):^Char;" marked as inline is not inlined
InlineHint.lpr(3,6) Hint: Unit "Unit1" not used in InlineHint
As you can see, there are two messages, including the reason for not inlining for (17,8), and Lazarus only shows one. Maybe because the second one is not "Note: " or because there are two for one line, or perhaps I missed an option.
Can anyone check this and let me know if I am missing something or it is an issue? The project is attached.