Browse Source

Avoid internal error 2002042430 and check overloading before calling simplify method

git-svn-id: trunk@20635 -
pierre 13 năm trước cách đây
mục cha
commit
7101151b5c
1 tập tin đã thay đổi với 15 bổ sung9 xóa
  1. 15 9
      compiler/nmat.pas

+ 15 - 9
compiler/nmat.pas

@@ -190,10 +190,6 @@ implementation
          maybe_call_procvar(left,true);
          maybe_call_procvar(right,true);
 
-         result:=simplify(false);
-         if assigned(result) then
-           exit;
-
          { allow operator overloading }
          t:=self;
          if isbinaryoverloaded(t) then
@@ -204,12 +200,22 @@ implementation
 
          { we need 2 orddefs always }
          if (left.resultdef.typ<>orddef) then
-           inserttypeconv(right,sinttype);
+           inserttypeconv(left,sinttype);
          if (right.resultdef.typ<>orddef) then
            inserttypeconv(right,sinttype);
          if codegenerror then
            exit;
 
+         { Try only now to simply constant
+           as otherwise you might create
+           tconstnode with return type that are
+           not compatible with tconst node
+           as in bug report 21566 PM }
+
+         result:=simplify(false);
+         if assigned(result) then
+           exit;
+
          rd:=torddef(right.resultdef);
          ld:=torddef(left.resultdef);
 
@@ -567,10 +573,6 @@ implementation
          maybe_call_procvar(left,true);
          maybe_call_procvar(right,true);
 
-         result:=simplify(false);
-         if assigned(result) then
-           exit;
-
          { allow operator overloading }
          t:=self;
          if isbinaryoverloaded(t) then
@@ -579,6 +581,10 @@ implementation
               exit;
            end;
 
+         result:=simplify(false);
+         if assigned(result) then
+           exit;
+
 {$ifdef cpunodefaultint}
          { for small cpus we use the smallest common type }
          if (left.resultdef.typ=orddef) and (right.resultdef.typ=orddef) then