소스 검색

* fixed overloading of div operator

git-svn-id: trunk@3513 -
florian 19 년 전
부모
커밋
281d6907d2
3개의 변경된 파일29개의 추가작업 그리고 12개의 파일을 삭제
  1. 1 0
      .gitattributes
  2. 12 12
      compiler/nmat.pas
  3. 16 0
      tests/webtbs/tw4624.pp

+ 1 - 0
.gitattributes

@@ -6779,6 +6779,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 - 12
compiler/nmat.pas

@@ -149,6 +149,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);
@@ -172,18 +184,6 @@ implementation
                end;
             end;
 
-         result:=simplify;
-         if assigned(result) then
-           exit;
-
-         { 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.