* fix #39745: the conversion from ordinals to pointer types in mode Delphi is not allowed for a void type (happens when using a typecast to convert a method without parameters to a function reference)

+ added test
This commit is contained in:
Sven/Sarah Barth 2022-05-30 23:05:45 +02:00
parent 252707a873
commit 5a680f0148
2 changed files with 43 additions and 1 deletions

View File

@ -1988,7 +1988,10 @@ implementation
}
else if (not(target_info.system in systems_jvm) and
((def_from.typ=enumdef) or
(def_from.typ=orddef))) and
(
(def_from.typ=orddef) and
not is_void(def_from)
))) and
(m_delphi in current_settings.modeswitches) and
(cdo_explicit in cdoptions) then
begin

39
tests/webtbs/tw39745.pp Normal file
View File

@ -0,0 +1,39 @@
{ %NORUN }
program tw39745;
{$mode delphi} // objfpc is ok
{$modeswitch functionreferences}
//uses classes;
type
TThreadMethod = procedure of object;
TThreadProcedure = reference to procedure;
TThread = class
procedure Queue(aMethod: TThreadMethod);overload;
procedure Queue(aFuncRef: TThreadProcedure);overload;
end;
TTestThread = class(tthread)
procedure something; // matches tthreadmethod
procedure xx;
end;
procedure tthread.Queue(aMethod: TThreadMethod);
begin
end;
procedure tthread.Queue(aFuncRef: TThreadProcedure);
begin
end;
procedure ttestthread.something;
begin
end;
procedure ttestthread.xx;
begin
Queue(tthreadprocedure(Something)); // add @ for mode objfpc
end;
begin
end.