Browse Source

bugs 242-245

pierre 26 years ago
parent
commit
12ec9e475d
4 changed files with 113 additions and 0 deletions
  1. 26 0
      tests/tbf0245.pp
  2. 28 0
      tests/tbs0242b.pp
  3. 35 0
      tests/tbs0243.pp
  4. 24 0
      tests/tbs0244.pp

+ 26 - 0
tests/tbf0245.pp

@@ -0,0 +1,26 @@
+const
+ r = 3.5;
+ s = 'test idiot';
+type
+  preal = ^real;
+  pstring = ^string;
+
+  procedure ss;
+   begin
+   end;
+   
+var
+  p : pointer;
+  pr : preal;
+  ps : pstring;
+
+  begin
+   p:=@ss;
+   p:=@s;
+   pr:=@r;
+   ps:=@s;
+   pr^:=7.8;
+   ps^:='test3';
+   Writeln('r=',r,' s=',s);
+  end.
+   

+ 28 - 0
tests/tbs0242b.pp

@@ -0,0 +1,28 @@
+
+const
+  test = 5;
+
+  procedure test_const(const s : string;const x);
+    begin
+      writeln(s,' is ',longint(x));
+    end;
+    
+  procedure change(var x);
+    begin
+      inc(longint(x));
+    end;
+  const i : longint = 12;
+  var
+     j : longint;
+begin
+  j:=34;
+  test_const('Const 5',5);
+  test_const('Untyped const test',test);
+  test_const('Typed_const i',i);
+  test_const('Var j',j);
+  {test_const('i<>j ',i<>j);}
+  change(i);
+  change(j);
+  { change(test);
+  change(longint); }
+end.

+ 35 - 0
tests/tbs0243.pp

@@ -0,0 +1,35 @@
+program simpletest;
+
+var i : longint;
+
+  function _next : longint;
+    begin
+      inc(i);
+      _next:=i;
+    end;
+
+  procedure test(a,b : longint);
+    begin
+      Writeln('first arg is ',a);
+      Writeln('second arg is ',b);
+    end;
+
+  procedure check(a,b : longint);
+    begin
+      if a>b then
+        begin
+           Writeln('FPC does not follow PASCAL rules for parameter passing');
+           Halt(1);
+        end;
+    end;
+
+begin
+{ this could give 
+  first arg is 1
+  second arg is 2 
+  but FPC parses the second arg before the first one ! }
+test(_next,_next);
+writeln('third arg is ',_next);
+writeln('fourth arg is ',_next,' fifth arg is ',_next);
+check(_next,_next);
+end.

+ 24 - 0
tests/tbs0244.pp

@@ -0,0 +1,24 @@
+Unit bug0244;
+
+{test also with -So !!!}
+
+Interface
+
+Procedure t(a,b: longint);
+
+Implementation
+
+Procedure t(a,b: longint);
+begin
+end;
+
+Procedure t2;
+
+  Procedure t(l: Longint);
+  Begin
+  End;
+
+Begin
+End;
+
+End.