浏览代码

* fixed code which causes range check errors when compiled with -Cr

git-svn-id: trunk@23889 -
florian 12 年之前
父节点
当前提交
20a534e63f
共有 3 个文件被更改,包括 17 次插入6 次删除
  1. 3 0
      compiler/ogbase.pas
  2. 13 5
      compiler/scanner.pas
  3. 1 1
      compiler/x86/itx86int.pas

+ 3 - 0
compiler/ogbase.pas

@@ -1315,7 +1315,10 @@ implementation
             hstab.strpos:=1;
             hstab.ntype:=0;
             hstab.nother:=0;
+{$push}{$R-}
+            { for jwawindows.pas, this causes an range check error, it contains too much stab symbols }
             hstab.ndesc:=(StabsSec.Size div sizeof(TObjStabEntry))-1;
+{$pop}
             hstab.nvalue:=StabStrSec.Size;
             MaybeSwapStab(hstab);
             StabsSec.Data.seek(0);

+ 13 - 5
compiler/scanner.pas

@@ -2629,13 +2629,15 @@ In case not, the value returned can be arbitrary.
           _CWSTRING :
             begin
               tokenwritesizeint(patternw^.len);
-              recordtokenbuf.write(patternw^.data^,patternw^.len*sizeof(tcompilerwidechar));
+              if patternw^.len>0 then
+                recordtokenbuf.write(patternw^.data^,patternw^.len*sizeof(tcompilerwidechar));
             end;
           _CSTRING:
             begin
               len:=length(cstringpattern);
               tokenwritesizeint(len);
-              recordtokenbuf.write(cstringpattern[1],len);
+              if len>0 then
+                recordtokenbuf.write(cstringpattern[1],len);
             end;
           _CCHAR,
           _INTCONST,
@@ -2731,7 +2733,8 @@ In case not, the value returned can be arbitrary.
               begin
                 wlen:=tokenreadsizeint;
                 setlengthwidestring(patternw,wlen);
-                replaytokenbuf.read(patternw^.data^,patternw^.len*sizeof(tcompilerwidechar));
+                if wlen>0 then
+                  replaytokenbuf.read(patternw^.data^,patternw^.len*sizeof(tcompilerwidechar));
                 orgpattern:='';
                 pattern:='';
                 cstringpattern:='';
@@ -2739,8 +2742,13 @@ In case not, the value returned can be arbitrary.
             _CSTRING:
               begin
                 wlen:=tokenreadsizeint;
-                setlength(cstringpattern,wlen);
-                replaytokenbuf.read(cstringpattern[1],wlen);
+                if wlen>0 then
+                  begin
+                    setlength(cstringpattern,wlen);
+                    replaytokenbuf.read(cstringpattern[1],wlen);
+                  end
+                else
+                  cstringpattern:='';
                 orgpattern:='';
                 pattern:='';
               end;

+ 1 - 1
compiler/x86/itx86int.pas

@@ -72,7 +72,7 @@ implementation
             else r := m;
           end;
 
-        if int_regname_table[int_regname_index[r]]=s then
+        if (r<=high(tregisterindex)) and (int_regname_table[int_regname_index[r]]=s) then
           findreg_by_intname:=int_regname_index[r]
         else
           findreg_by_intname:=0;