mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-04 19:08:21 +01:00
* 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:
parent
aeb3ea06d4
commit
b64c6c4c5e
@ -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
22
tests/test/toperator97.pp
Normal 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.
|
||||
Loading…
Reference in New Issue
Block a user