소스 검색

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/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

+ 12 - 9
compiler/pparautl.pas

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