Browse Source

*** empty log message ***

florian 25 years ago
parent
commit
fc39bd3f95
2 changed files with 34 additions and 0 deletions
  1. 1 0
      tests/testopt/readme.txt
  2. 33 0
      tests/testopt/testreg3.pp

+ 1 - 0
tests/testopt/readme.txt

@@ -2,5 +2,6 @@ This directory contains some tests which test the optimizer
 Register variables:
 Register variables:
   Enumerations .......................... testreg1.pp
   Enumerations .......................... testreg1.pp
   Readln ................................ testreg2.pp
   Readln ................................ testreg2.pp
+  Range checking ........................ testreg3.pp
 Common subexpression elimination (assembler)
 Common subexpression elimination (assembler)
   Multidimensional array index operation. testcse1.pp 
   Multidimensional array index operation. testcse1.pp 

+ 33 - 0
tests/testopt/testreg3.pp

@@ -0,0 +1,33 @@
+{ $OPT=-Or}
+program rangecse;
+
+{$r+}
+
+type
+  pa = ^ta;
+  ta = array[0..100] of longint;
+
+procedure t;
+var
+  i, j: longint;
+  p: pa;
+begin
+  new(p);
+  fillchar(p^,101*sizeof(longint),0);
+  p^[100] := 5;
+  j := 5;
+  for i:=1 to 101 do
+   if j=p^[i-1] then
+    begin
+      writeln('found!');
+      dispose(p);
+      exit;
+    end;
+  writeln('failed..');
+  dispose(p);
+  halt(1);
+end;
+
+begin
+  t;
+end.