Static methods not recognized as valid function reference in FPC mode.
Summary
When taking the address of a static class method, the compiler works correctly in mode Delphi, but not in mode objfpc.
System Information
- Operating system: N/A
- Processor architecture: N/A
- Compiler version: 3.3.1
- Device: N/A
Steps to reproduce
- Compile below program without define USEOBJFPC. It will compile in mode delphi
- Compile below program with define USEOBJFPC. It will compile in mode ObjFPC, but the compiler will give an error
ta.pp(30,6) Error: Incompatible types: got "<class method type of procedure(LongInt) of object;Register>" expected "TSOMEPROC"
Example Project
program ttestproc;
{$IFDEF USEOBJFPC}
{$mode objfpc}
{$modeswitch functionreferences}
{$ELSE}
{$MODE DELPHI}
{$ENDIF}
Type
TSomeClass = class(TObject)
class procedure Y (X : Integer); static;
end;
TSomeProc = reference to procedure (X : integer);
Var
P : TSomeProc;
class procedure TSomeClass.Y(X : Integer);
begin
Writeln(X);
end;
var
C : TSomeClass;
begin
C:=TSomeClass.Create;
{$IFDEF USEOBJFPC}
P:=@C.Y;
{$ELSE}
P:=C.Y;
{$ENDIF}
end.
What is the current bug behavior?
Compiler gives an error in mode objfpc but not in mode Delphi
What is the expected (correct) behavior?
Compiler compiles in mode objfpc as in mode delphi.