mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 01:39:27 +02:00
* x86 Intel asm reader: handle special variables "self" and "result" similar to regular ones in terms of subscripting. This makes fix from r34911 apply to these special variables. Resolves #31542.
git-svn-id: trunk@35669 -
This commit is contained in:
parent
52c9e272d2
commit
8ae0864c9a
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -12045,6 +12045,7 @@ tests/test/tarrconstr2.pp svneol=native#text/pascal
|
||||
tests/test/tarrconstr3.pp svneol=native#text/pascal
|
||||
tests/test/tarrconstr4.pp svneol=native#text/pascal
|
||||
tests/test/tasm1.pp svneol=native#text/plain
|
||||
tests/test/tasm10.pp svneol=native#text/plain
|
||||
tests/test/tasm2.inc svneol=native#text/plain
|
||||
tests/test/tasm2.pp svneol=native#text/plain
|
||||
tests/test/tasm2a.pp svneol=native#text/plain
|
||||
|
@ -1862,6 +1862,7 @@ Unit Rax86int;
|
||||
Begin
|
||||
oper.SetupResult;
|
||||
Consume(AS_ID);
|
||||
expr:='result';
|
||||
end
|
||||
else
|
||||
if (actasmpattern = '@CODE') or (actasmpattern = '@DATA') then
|
||||
@ -1887,6 +1888,7 @@ Unit Rax86int;
|
||||
begin
|
||||
oper.SetUpResult;
|
||||
Consume(AS_ID);
|
||||
expr:='result';
|
||||
end
|
||||
{ probably a variable or normal expression }
|
||||
{ or a procedure (such as in CALL ID) }
|
||||
@ -1961,10 +1963,15 @@ Unit Rax86int;
|
||||
Begin
|
||||
{ not a variable, check special variables.. }
|
||||
if expr = 'SELF' then
|
||||
oper.SetupSelf
|
||||
begin
|
||||
oper.SetupSelf;
|
||||
expr:='self';
|
||||
end
|
||||
else
|
||||
Message1(sym_e_unknown_id,expr);
|
||||
expr:='';
|
||||
begin
|
||||
Message1(sym_e_unknown_id,expr);
|
||||
expr:='';
|
||||
end;
|
||||
end;
|
||||
{ indexed access to variable? }
|
||||
if actasmtoken=AS_LBRACKET then
|
||||
|
54
tests/test/tasm10.pp
Normal file
54
tests/test/tasm10.pp
Normal file
@ -0,0 +1,54 @@
|
||||
{ %CPU=x86_64 }
|
||||
{ Tests that object fields with zero offset are handled by Intel assembler reader
|
||||
the same way as fields with nonzero offset }
|
||||
{$ifdef fpc}
|
||||
{$mode delphi}
|
||||
{$asmmode intel}
|
||||
{$endif}
|
||||
|
||||
type
|
||||
TTest=object
|
||||
Data1,Data2:Integer;
|
||||
procedure Setter;
|
||||
function Getter1: TTest;
|
||||
function Getter2: TTest;
|
||||
end;
|
||||
|
||||
|
||||
procedure TTest.Setter; assembler;
|
||||
asm
|
||||
mov Self.Data1,1234
|
||||
mov Self.Data2,5678
|
||||
end;
|
||||
|
||||
function TTest.Getter1: TTest; assembler;
|
||||
asm
|
||||
mov eax,Self.Data1
|
||||
mov result.Data1, eax
|
||||
mov eax,Self.Data2
|
||||
mov result.Data2, eax
|
||||
end;
|
||||
|
||||
|
||||
function TTest.Getter2: TTest; assembler;
|
||||
asm
|
||||
mov eax,Self.Data1
|
||||
mov @result.Data1, eax
|
||||
mov eax,Self.Data2
|
||||
mov @result.Data2, eax
|
||||
end;
|
||||
|
||||
var
|
||||
testobj, testobj2: TTest;
|
||||
|
||||
begin
|
||||
testobj.Setter;
|
||||
testobj2:=testobj.Getter1;
|
||||
if (testobj2.Data1 <> 1234) or (testobj2.Data2 <> 5678) then
|
||||
Halt(1);
|
||||
testobj2:=testobj.Getter2;
|
||||
if (testobj2.Data1 <> 1234) or (testobj2.Data2 <> 5678) then
|
||||
Halt(2);
|
||||
writeln('ok');
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user