浏览代码

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 -
paul 12 年之前
父节点
当前提交
cdd5d029f0
共有 3 个文件被更改,包括 68 次插入9 次删除
  1. 1 0
      .gitattributes
  2. 12 9
      compiler/pparautl.pas
  3. 55 0
      tests/webtbs/tw25081.pp

+ 1 - 0
.gitattributes

@@ -13594,6 +13594,7 @@ tests/webtbs/tw25054a.pp svneol=native#text/pascal
 tests/webtbs/tw25054b.pp svneol=native#text/pascal
 tests/webtbs/tw25054b.pp svneol=native#text/pascal
 tests/webtbs/tw25059.pp svneol=native#text/pascal
 tests/webtbs/tw25059.pp svneol=native#text/pascal
 tests/webtbs/tw25077.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/tw2514.pp svneol=native#text/plain
 tests/webtbs/tw2525.pp svneol=native#text/plain
 tests/webtbs/tw2525.pp svneol=native#text/plain
 tests/webtbs/tw2536.pp svneol=native#text/plain
 tests/webtbs/tw2536.pp svneol=native#text/plain

+ 12 - 9
compiler/pparautl.pas

@@ -265,15 +265,18 @@ implementation
            { insert the name of the procedure as alias for the function result,
            { insert the name of the procedure as alias for the function result,
              we can't use realname because that will not work for compilerprocs
              we can't use realname because that will not work for compilerprocs
              as the name is lowercase and unreachable from the code }
              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 }
            { insert result also if support is on }
            if (m_result in current_settings.modeswitches) then
            if (m_result in current_settings.modeswitches) then

+ 55 - 0
tests/webtbs/tw25081.pp

@@ -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.