* when searching for an assignment operator to a typed pointer type then also search for an assignment operator to an untyped pointer if nothing suitable was found

+ added test
This commit is contained in:
Sven/Sarah Barth 2025-10-21 23:27:55 +02:00
parent aeb3ea06d4
commit b64c6c4c5e
2 changed files with 32 additions and 0 deletions

View File

@ -4275,6 +4275,16 @@ implementation
if result=nil then
result:=search_specific_assignment_operator(_ASSIGNMENT,from_def,to_def);
{ if we're assigning to a typed pointer, but we did not find a suitable assignement
operator then we also check for a untyped pointer assignment operator }
if not assigned(result) and is_pointer(to_def) and not is_voidpointer(to_def) then
begin
if explicit then
result:=search_specific_assignment_operator(_OP_EXPLICIT,from_def,voidpointertype);
if not assigned(result) then
result:=search_specific_assignment_operator(_ASSIGNMENT,from_def,voidpointertype);
end;
{ restore symtable stack }
if to_def.typ in [recorddef,objectdef] then
symtablestack.pop(tabstractrecorddef(to_def).symtable);

22
tests/test/toperator97.pp Normal file
View File

@ -0,0 +1,22 @@
{ %NORUN }
program toperator97;
{$mode objfpc}
{$modeswitch advancedrecords}
type
TTest = record
class operator :=(aArg: TTest): Pointer;
end;
class operator TTest.:=(aArg: TTest): Pointer;
begin
end;
var
b: PByte;
t: TTest;
begin
b := t;
end.