소스 검색

Merged revisions 3513 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

r3513 (florian)
* fixed overloading of div operator

git-svn-id: branches/fixes_2_0@3516 -

florian 19 년 전
부모
커밋
1c1bea2b29
3개의 변경된 파일29개의 추가작업 그리고 8개의 파일을 삭제
  1. 1 0
      .gitattributes
  2. 12 8
      compiler/nmat.pas
  3. 16 0
      tests/webtbs/tw4624.pp

+ 1 - 0
.gitattributes

@@ -6450,6 +6450,7 @@ tests/webtbs/tw4574.pp svneol=native#text/plain
 tests/webtbs/tw4599.pp svneol=native#text/plain
 tests/webtbs/tw4613.pp -text svneol=unset#text/plain
 tests/webtbs/tw4616.pp svneol=native#text/plain
+tests/webtbs/tw4624.pp -text svneol=unset#text/plain
 tests/webtbs/tw4632.pp svneol=native#text/plain
 tests/webtbs/tw4633.pp svneol=native#text/plain
 tests/webtbs/tw4634.pp -text

+ 12 - 8
compiler/nmat.pas

@@ -110,6 +110,18 @@ implementation
          if codegenerror then
            exit;
 
+         result:=simplify;
+         if assigned(result) then
+           exit;
+
+         { allow operator overloading }
+         t:=self;
+         if isbinaryoverloaded(t) then
+           begin
+              result:=t;
+              exit;
+           end;
+
          { we need 2 orddefs always }
          if (left.resulttype.def.deftype<>orddef) then
            inserttypeconv(right,sinttype);
@@ -154,14 +166,6 @@ implementation
               end;
             end;
 
-         { allow operator overloading }
-         t:=self;
-         if isbinaryoverloaded(t) then
-           begin
-              result:=t;
-              exit;
-           end;
-
          { if one operand is a cardinal and the other is a positive constant, convert the }
          { constant to a cardinal as well so we don't have to do a 64bit division (JM)    }
          { Do the same for qwords and positive constants as well, otherwise things like   }

+ 16 - 0
tests/webtbs/tw4624.pp

@@ -0,0 +1,16 @@
+{ Source provided for Free Pascal Bug Report 4624 }
+{ Submitted by "benoit sanchez" on  2005-12-20 }
+{ e-mail: [email protected] }
+type Number=record
+  value:boolean;
+end;
+
+operator div (a,b:number) c:number;
+begin
+  c.value:=true;
+end;
+
+var a:number;
+begin
+  a:=a div a;
+end.