فهرست منبع

* Reduce false positives of type_h_use_div_for_int.

git-svn-id: trunk@7590 -
daniel 18 سال پیش
والد
کامیت
fe5118e903
2فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 1 4
      compiler/nadd.pas
  2. 5 0
      compiler/ncnv.pas

+ 1 - 4
compiler/nadd.pas

@@ -823,10 +823,7 @@ implementation
                 begin
                   left.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(left,resultrealdef);
           end

+ 5 - 0
compiler/ncnv.pas

@@ -608,6 +608,11 @@ implementation
          if def=nil then
           internalerror(200103281);
          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;