Browse Source

* make more use of nf_internal to avoid range check errors

git-svn-id: trunk@34793 -
florian 8 năm trước cách đây
mục cha
commit
000cffa8e3
5 tập tin đã thay đổi với 20 bổ sung12 xóa
  1. 2 2
      compiler/ncgcnv.pas
  2. 3 2
      compiler/ncnv.pas
  3. 4 4
      compiler/nflw.pas
  4. 10 3
      compiler/ninl.pas
  5. 1 1
      compiler/nld.pas

+ 2 - 2
compiler/ncgcnv.pas

@@ -103,8 +103,8 @@ interface
       begin
         newsize:=def_cgsize(resultdef);
 
-        { insert range check if not explicit conversion }
-        if not(nf_explicit in flags) then
+        { insert range check if not explicit or interally generated conversion }
+        if (flags*[nf_explicit,nf_internal])=[] then
           hlcg.g_rangecheck(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef);
 
         { is the result size smaller? when typecasting from void

+ 3 - 2
compiler/ncnv.pas

@@ -2785,8 +2785,9 @@ implementation
                        { for constant values on absolute variables, swaping is required }
                        if (target_info.endian = endian_big) and (nf_absolute in flags) then
                          swap_const_value(tordconstnode(left).value,tordconstnode(left).resultdef.size);
-                       testrange(resultdef,tordconstnode(left).value,(nf_explicit in flags)
-                                 or (nf_absolute in flags),false);
+                       if not(nf_internal in flags) then
+                         testrange(resultdef,tordconstnode(left).value,(nf_explicit in flags)
+                                   or (nf_absolute in flags),false);
                        { swap value back, but according to new type }
                        if (target_info.endian = endian_big) and (nf_absolute in flags) then
                          swap_const_value(tordconstnode(left).value,resultdef.size);

+ 4 - 4
compiler/nflw.pas

@@ -1685,7 +1685,7 @@ implementation
             else
               toexpr:=t1.getcopy;
 
-            addstatement(ifstatements,cwhilerepeatnode.create(caddnode.create(cond,left.getcopy,toexpr),loopblock,false,true));
+            addstatement(ifstatements,cwhilerepeatnode.create(caddnode.create_internal(cond,left.getcopy,toexpr),loopblock,false,true));
 
             if usefromtemp then
               fromexpr:=ctemprefnode.create(fromtemp)
@@ -1698,10 +1698,10 @@ implementation
               toexpr:=t1.getcopy;
 
             if lnf_backward in loopflags then
-              addstatement(statements,cifnode.create(caddnode.create(gten,
+              addstatement(statements,cifnode.create(caddnode.create_internal(gten,
                 fromexpr,toexpr),ifblock,nil))
             else
-              addstatement(statements,cifnode.create(caddnode.create(lten,
+              addstatement(statements,cifnode.create(caddnode.create_internal(lten,
                 fromexpr,toexpr),ifblock,nil));
 
             if usetotemp then
@@ -1711,7 +1711,7 @@ implementation
           end
         else
           begin
-            addstatement(ifstatements,cwhilerepeatnode.create(caddnode.create(cond,left.getcopy,t1.getcopy),loopblock,false,true));
+            addstatement(ifstatements,cwhilerepeatnode.create(caddnode.create_internal(cond,left.getcopy,t1.getcopy),loopblock,false,true));
             addstatement(statements,ifblock);
           end;
       end;

+ 10 - 3
compiler/ninl.pas

@@ -3457,6 +3457,7 @@ implementation
                     hp:=caddnode.create(addn,left,hp)
                   else
                     hp:=caddnode.create(subn,left,hp);
+
                   { assign result of addition }
                   if not(is_integer(resultdef)) then
                     inserttypeconv(hp,corddef.create(
@@ -3471,6 +3472,9 @@ implementation
                   else
                     inserttypeconv(hp,resultdef);
 
+                  if nf_internal in flags then
+                    include(hp.flags,nf_internal);
+
                   { avoid any possible errors/warnings }
                   inserttypeconv_internal(hp,resultdef);
 
@@ -3899,9 +3903,9 @@ implementation
 
          { addition/substraction depending on inc/dec }
          if inlinenumber = in_inc_x then
-           hpp := caddnode.create(addn,hp,hpp)
+           hpp := caddnode.create_internal(addn,hp,hpp)
          else
-           hpp := caddnode.create(subn,hp,hpp);
+           hpp := caddnode.create_internal(subn,hp,hpp);
          { assign result of addition }
          if not(is_integer(resultnode.resultdef)) then
            inserttypeconv(hpp,corddef.create(
@@ -3914,7 +3918,10 @@ implementation
              get_max_value(resultnode.resultdef),
              true))
          else
-           inserttypeconv(hpp,resultnode.resultdef);
+           if nf_internal in flags then
+             inserttypeconv_internal(hpp,resultnode.resultdef)
+           else
+             inserttypeconv(hpp,resultnode.resultdef);
 
          { avoid any possible warnings }
          inserttypeconv_internal(hpp,resultnode.resultdef);

+ 1 - 1
compiler/nld.pas

@@ -577,7 +577,7 @@ implementation
                 in_inc_x,false,ccallparanode.create(
                 left.getcopy,nil))
             else
-              result:=cinlinenode.create(
+              result:=cinlinenode.createintern(
                 in_dec_x,false,ccallparanode.create(
                 left.getcopy,nil));
             exit;