[fpc-devel] LLVM, interfaces and nested procedure variables

Jonas Maebe jonas at freepascal.org
Sat Nov 25 13:08:35 CET 2023


On 25/11/2023 12:48, Kieran via fpc-devel wrote:
> I'm trying to reproduce a minimal viable demo of a problem compiling 
> code using the LLVM backend that has an interface with a parameter 
> that is a nested procedure variable, but I'm not having any luck. I've 
> noticed the difference between my test programs and the large project 
> where I'm seeing the issue reliably is that when compiling the larger 
> project, the line "Parsing internally generated code" (I think that's 
> error string 3319/"Parsen intern erzeugten") gets output with what looks 
> like interface method shims for an object -- methods prefixed "WRPR_".
> 
>   I can't get my test programs to do the same even when trying the same 
> compiler arguments and directives

That should happen whenever you implement an interface method in a class.

I can reproduce the issue with the program in attachment.


Jonas
-------------- next part --------------
{$mode objfpc}
{$modeswitch nestedprocvars}

type
  TNestedProc = procedure is nested;

IInf = interface
    procedure InfMethod(AParam: TNestedProc);
end;

TObj = class(TInterfacedObject, IInf)
  procedure InfMethod(AParam: TNestedProc);
end;

procedure TObj.InfMethod(AParam: TNestedProc);
begin
end;

procedure test(o: TObj);

  procedure nest;
    begin
    end;

begin
  o.InfMethod(@nest);
end;

begin
end.


More information about the fpc-devel mailing list