mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 06:08:16 +02:00
compiler: don't add operator name as a function result into operator symtable. For FPC mode only operator result identifier should be added and for Delphi mode only 'Result' identifier. Fixes mantis #0025081
git-svn-id: trunk@25562 -
This commit is contained in:
parent
c22c364f43
commit
cdd5d029f0
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -13594,6 +13594,7 @@ tests/webtbs/tw25054a.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25054b.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25059.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25077.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25081.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw2514.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2525.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2536.pp svneol=native#text/plain
|
||||
|
@ -265,15 +265,18 @@ implementation
|
||||
{ insert the name of the procedure as alias for the function result,
|
||||
we can't use realname because that will not work for compilerprocs
|
||||
as the name is lowercase and unreachable from the code }
|
||||
if assigned(pd.resultname) then
|
||||
hs:=pd.resultname^
|
||||
else
|
||||
hs:=pd.procsym.name;
|
||||
sl:=tpropaccesslist.create;
|
||||
sl.addsym(sl_load,pd.funcretsym);
|
||||
aliasvs:=tabsolutevarsym.create_ref(hs,pd.returndef,sl);
|
||||
include(aliasvs.varoptions,vo_is_funcret);
|
||||
tlocalsymtable(pd.localst).insert(aliasvs);
|
||||
if (pd.proctypeoption<>potype_operator) or assigned(pd.resultname) then
|
||||
begin
|
||||
if assigned(pd.resultname) then
|
||||
hs:=pd.resultname^
|
||||
else
|
||||
hs:=pd.procsym.name;
|
||||
sl:=tpropaccesslist.create;
|
||||
sl.addsym(sl_load,pd.funcretsym);
|
||||
aliasvs:=tabsolutevarsym.create_ref(hs,pd.returndef,sl);
|
||||
include(aliasvs.varoptions,vo_is_funcret);
|
||||
tlocalsymtable(pd.localst).insert(aliasvs);
|
||||
end;
|
||||
|
||||
{ insert result also if support is on }
|
||||
if (m_result in current_settings.modeswitches) then
|
||||
|
55
tests/webtbs/tw25081.pp
Normal file
55
tests/webtbs/tw25081.pp
Normal file
@ -0,0 +1,55 @@
|
||||
program tw25081;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
type
|
||||
TLargeCardinal = record
|
||||
public
|
||||
Low: Cardinal;
|
||||
High: Cardinal;
|
||||
|
||||
class operator Inc(const Operand: TLargeCardinal): TLargeCardinal;
|
||||
class operator Dec(const Operand: TLargeCardinal): TLargeCardinal;
|
||||
end;
|
||||
|
||||
{ TLargeCardinal }
|
||||
|
||||
class operator TLargeCardinal.Dec(const Operand: TLargeCardinal): TLargeCardinal;
|
||||
begin
|
||||
Result := Operand;
|
||||
Dec(Result.Low);
|
||||
|
||||
if Result.Low = $FFFFFFFF then
|
||||
Dec(Result.High);
|
||||
end;
|
||||
|
||||
class operator TLargeCardinal.Inc(const Operand: TLargeCardinal): TLargeCardinal;
|
||||
begin
|
||||
Result := Operand;
|
||||
Inc(Result.Low);
|
||||
|
||||
if Result.Low = 0 then
|
||||
Inc(Result.High);
|
||||
end;
|
||||
|
||||
var
|
||||
Value: TLargeCardinal;
|
||||
|
||||
begin
|
||||
Value.Low := $FFFFFFFF;
|
||||
Value.High := 0;
|
||||
|
||||
Inc(Value);
|
||||
|
||||
if (Value.Low <> 0) or (Value.High <> 1) then
|
||||
Halt(1);
|
||||
|
||||
Dec(Value);
|
||||
|
||||
if (Value.Low <> $FFFFFFFF) or (Value.High <> 0) then
|
||||
Halt(1);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user