Browse Source

* Reduce false positives of type_h_use_div_for_int.

git-svn-id: trunk@7590 -
daniel 18 years ago
parent
commit
fe5118e903
2 changed files with 6 additions and 4 deletions
  1. 1 4
      compiler/nadd.pas
  2. 5 0
      compiler/ncnv.pas

+ 1 - 4
compiler/nadd.pas

@@ -823,10 +823,7 @@ implementation
                 begin
                 begin
                   left.resultdef := s64inttype;
                   left.resultdef := s64inttype;
                   right.resultdef := s64inttype;
                   right.resultdef := s64inttype;
-                end
-            else if (left.resultdef.typ <> floatdef) and
-               (right.resultdef.typ <> floatdef) then
-              CGMessage(type_h_use_div_for_int);
+                end;
             inserttypeconv(right,resultrealdef);
             inserttypeconv(right,resultrealdef);
             inserttypeconv(left,resultrealdef);
             inserttypeconv(left,resultrealdef);
           end
           end

+ 5 - 0
compiler/ncnv.pas

@@ -608,6 +608,11 @@ implementation
          if def=nil then
          if def=nil then
           internalerror(200103281);
           internalerror(200103281);
          fileinfo:=node.fileinfo;
          fileinfo:=node.fileinfo;
+         {An attempt to convert the result of a floating point division
+          (with the / operator) to an integer type will fail. Give a hint
+          to use the div operator.}
+          if (node.nodetype=slashn) and (def.typ=orddef) then
+            cgmessage(type_h_use_div_for_int);
       end;
       end;