Pārlūkot izejas kodu

* overflow,rangecheck optional parameters for operators, patch from 8281

git-svn-id: branches/fpc_2_3@6386 -
peter 18 gadi atpakaļ
vecāks
revīzija
27f79a66a0
3 mainītis faili ar 49 papildinājumiem un 4 dzēšanām
  1. 35 2
      compiler/htypechk.pas
  2. 11 1
      compiler/ncal.pas
  3. 3 1
      compiler/symconst.pas

+ 35 - 2
compiler/htypechk.pas

@@ -157,11 +157,12 @@ interface
 implementation
 
     uses
+       sysutils,
        globtype,systems,
        cutils,cclasses,verbose,
        symtable,
        defutil,defcmp,
-       nbas,ncnv,nld,nmem,ncal,nmat,ninl,nutils,
+       nbas,ncnv,nld,nmem,ncal,nmat,ninl,nutils,ncon,
        cgbase,procinfo
        ;
 
@@ -358,9 +359,41 @@ implementation
         eq : tequaltype;
         conv : tconverttype;
         pd : tprocdef;
+        oldcount,
+        count: longint;
+        parasym : tparavarsym;
       begin
         result:=false;
-        case pf.parast.SymList.count of
+        count := pf.parast.SymList.count;
+
+        oldcount:=count;
+        while count > 0 do
+          begin
+            parasym:=tparavarsym(pf.parast.SymList[count-1]);
+            if is_boolean(parasym.vardef) then
+              begin
+                if parasym.name='RANGECHECK' then
+                  begin
+                    Include(parasym.varoptions, vo_is_hidden_para);
+                    Include(parasym.varoptions, vo_is_range_check);
+                    Dec(count);
+                  end
+                else if parasym.name='OVERFLOWCHECK' then
+                  begin
+                    Include(parasym.varoptions, vo_is_hidden_para);
+                    Include(parasym.varoptions, vo_is_overflow_check);
+                    Dec(count);
+                  end
+                else
+                  break;
+              end
+            else
+              break;
+          end;
+        if count<>oldcount then
+          pf.calcparas;
+
+        case count of
           1 : begin
                 ld:=tparavarsym(pf.parast.SymList[0]).vardef;
                 { assignment is a special case }

+ 11 - 1
compiler/ncal.pas

@@ -1597,7 +1597,7 @@ implementation
                 if (procdefinition.proctypeoption=potype_destructor) then
                   if not(cnf_create_failed in callnodeflags) then
                     vmttree:=cpointerconstnode.create(1,voidpointertype)
-                  else 
+                  else
                     vmttree:=cpointerconstnode.create(TConstPtrUInt(-1),voidpointertype)
                 else
                   begin
@@ -1749,6 +1749,16 @@ implementation
                    if not(assigned(procdefinition.owner.defowner)) then
                      internalerror(200309287);
                    hiddentree:=cloadparentfpnode.create(tprocdef(procdefinition.owner.defowner));
+                 end
+              else
+               if vo_is_range_check in currpara.varoptions then
+                 begin
+                   hiddentree:=cordconstnode.create(Ord(cs_check_range in current_settings.localswitches),booltype,false);
+                 end
+              else
+               if vo_is_overflow_check in currpara.varoptions then
+                 begin
+                   hiddentree:=cordconstnode.create(Ord(cs_check_overflow in current_settings.localswitches),booltype,false);
                  end;
               { add the hidden parameter }
               if not assigned(hiddentree) then

+ 3 - 1
compiler/symconst.pas

@@ -353,7 +353,9 @@ type
     vo_has_explicit_paraloc,
     vo_is_syscall_lib,
     vo_has_mangledname,
-    vo_is_typed_const
+    vo_is_typed_const,
+    vo_is_range_check,
+    vo_is_overflow_check
   );
   tvaroptions=set of tvaroption;