Bladeren bron

Merged revisions 3182,3191-3193,3195,3197-3198,3200 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r3182 | jonas | 2006-04-09 20:14:44 +0200 (Sun, 09 Apr 2006) | 2 lines

* return error exit if test fails

........
r3191 | jonas | 2006-04-11 17:08:07 +0200 (Tue, 11 Apr 2006) | 3 lines

* fixed regvar bug in in-node code (regvar could be modified by
"in" code)

........
r3192 | jonas | 2006-04-11 22:41:53 +0200 (Tue, 11 Apr 2006) | 3 lines

+ support for {$calling default} to switch back to the default calling
convention

........
r3193 | jonas | 2006-04-12 09:58:25 +0200 (Wed, 12 Apr 2006) | 3 lines

* give an error for {$calling } (i.e., when a procedure directive is
missing)

........
r3195 | jonas | 2006-04-12 12:46:21 +0200 (Wed, 12 Apr 2006) | 2 lines

* fixed previous commit

........
r3197 | jonas | 2006-04-12 14:22:05 +0200 (Wed, 12 Apr 2006) | 2 lines

+ added test for empty {$calling }

........
r3198 | jonas | 2006-04-12 15:25:39 +0200 (Wed, 12 Apr 2006) | 2 lines

+ added

........
r3200 | jonas | 2006-04-13 11:00:40 +0200 (Thu, 13 Apr 2006) | 2 lines

+ added { %fail }

........

git-svn-id: branches/fixes_2_0@3206 -

Jonas Maebe 19 jaren geleden
bovenliggende
commit
6737e010dc
8 gewijzigde bestanden met toevoegingen van 136 en 5 verwijderingen
  1. 2 0
      .gitattributes
  2. 8 0
      compiler/globals.pas
  3. 5 2
      compiler/msg/errore.msg
  4. 2 2
      compiler/ncgset.pas
  5. 6 1
      compiler/scandir.pas
  6. 6 0
      tests/tbf/tb0180.pp
  7. 15 0
      tests/tbs/tb0500.pp
  8. 92 0
      tests/test/cg/tcnvint1.pp

+ 2 - 0
.gitattributes

@@ -4581,6 +4581,7 @@ tests/tbf/tb0176.pp svneol=native#text/plain
 tests/tbf/tb0177.pp svneol=native#text/plain
 tests/tbf/tb0178.pp svneol=native#text/plain
 tests/tbf/tb0179.pp svneol=native#text/plain
+tests/tbf/tb0180.pp svneol=native#text/plain
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain
@@ -5077,6 +5078,7 @@ tests/tbs/tb0497b.pp -text
 tests/tbs/tb0497c.pp -text
 tests/tbs/tb0498.pp svneol=native#text/plain
 tests/tbs/tb0499.pp svneol=native#text/plain
+tests/tbs/tb0500.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain

+ 8 - 0
compiler/globals.pas

@@ -1879,6 +1879,14 @@ end;
         t : tproccalloption;
       begin
         result:=false;
+        if (s = '') then
+          exit;
+        if (s = 'DEFAULT') then
+          begin
+            AktDefProcCall := pocall_default;
+            result := true;
+            exit;
+          end;
         for t:=low(tproccalloption) to high(tproccalloption) do
          if DefProcCallName[t]=s then
           begin

+ 5 - 2
compiler/msg/errore.msg

@@ -827,8 +827,11 @@ parser_e_only_publishable_classes_can__be_published=03156_E_Only class which are
 % are compiled in \var{\{\$M+\}} or which are derived from such a class. Normally
 % such a class should be derived from TPersitent
 parser_e_proc_directive_expected=03157_E_Procedure directive expected
-% When declaring a procedure in a const block you used a ; after the
-% procedure declaration after which a procedure directive must follow.
+% This error is triggered when you have a \var{\{\$Calling\}} directive without
+% a calling convention specified.
+% It also happens when declaring a procedure in a const block and you
+% used a ; after a procedure declaration which must be followed by a
+% procedure directive.
 % Correct declarations are:
 % \begin{verbatim}
 % const

+ 2 - 2
compiler/ncgset.pas

@@ -302,9 +302,9 @@ implementation
                       if (left.location.loc = LOC_CREGISTER) and
                          (hr<>pleftreg) then
                         begin
-                          cg.a_op_const_reg(exprasmlist,OP_SUB,opsize,setparts[i].start,pleftreg);
+                          { don't change this back to a_op_const_reg/a_load_reg_reg, since pleftreg must not be modified }
                           hr:=cg.getintregister(exprasmlist,opsize);
-                          cg.a_load_reg_reg(exprasmlist,opsize,opsize,pleftreg,hr);
+                          cg.a_op_const_reg_reg(exprasmlist,OP_SUB,opsize,setparts[i].start,pleftreg,hr);
                           pleftreg:=hr;
                         end
                       else

+ 6 - 1
compiler/scandir.pas

@@ -284,7 +284,12 @@ implementation
         current_scanner.skipspace;
         hs:=current_scanner.readid;
         if not SetAktProcCall(hs,false) then
-          Message1(parser_w_unknown_proc_directive_ignored,hs);
+          begin
+            if (hs <> '') then
+              Message1(parser_w_unknown_proc_directive_ignored,hs)
+            else
+              Message(parser_e_proc_directive_expected);
+          end;
       end;
 
 

+ 6 - 0
tests/tbf/tb0180.pp

@@ -0,0 +1,6 @@
+{ %fail }
+{ %OPT=-Sew }
+{$calling }
+
+begin
+end.

+ 15 - 0
tests/tbs/tb0500.pp

@@ -0,0 +1,15 @@
+{ %OPT=-Seh }
+program test;
+uses math;
+
+{ compiler claims that math isn't used, while the ** operator is used from it }
+
+function f(r: real; i: integer): int64;
+begin
+  f:= trunc(r**i);
+end;
+
+begin
+  writeln(f(2.0,2));
+end.
+

+ 92 - 0
tests/test/cg/tcnvint1.pp

@@ -38,91 +38,147 @@ begin
  bb1 := TRUE;
  tobyte := byte(bb1);
  WriteLn('boolean->byte : value should be 1...',tobyte);
+ if tobyte <> 1 then 
+   halt(1);
  bb1 := FALSE;
  tobyte := byte(bb1);
  WriteLn('boolean->byte : value should be 0...',tobyte);
+ if tobyte <> 0 then 
+   halt(1);
  bb1 := TRUE;
  toword := word(bb1);
  WriteLn('boolean->word : value should be 1...',toword);
+ if toword <> 1 then 
+   halt(1);
  bb1 := FALSE;
  toword := word(bb1);
  WriteLn('boolean->word : value should be 0...',toword);
+ if toword <> 0 then 
+   halt(1);
  bb1 := TRUE;
  tolong := longint(bb1);
  WriteLn('boolean->longint : value should be 1...',tolong);
+ if tolong <> 1 then 
+   halt(1);
  bb1 := FALSE;
  tolong := longint(bb1);
  WriteLn('boolean->longint : value should be 0...',tolong);
+ if tolong <> 0 then 
+   halt(1);
  wb1 := TRUE;
  tobyte := byte(wb1);
  WriteLn('wordbool->byte : value should be 1...',tobyte);
+ if tobyte <> 1 then 
+   halt(1);
  wb1 := FALSE;
  tobyte := byte(wb1);
  WriteLn('wordbool->byte : value should be 0...',tobyte);
+ if tobyte <> 0 then 
+   halt(1);
  wb1 := TRUE;
  toword := word(wb1);
  WriteLn('wordbool->word : value should be 1...',toword);
+ if toword <> 1 then 
+   halt(1);
  wb1 := FALSE;
  toword := word(wb1);
  WriteLn('wordbool->word : value should be 0...',toword);
+ if toword <> 0 then 
+   halt(1);
  wb1 := TRUE;
  tolong := longint(wb1);
  WriteLn('wordbool->longint : value should be 1...',tolong);
+ if tolong <> 1 then 
+   halt(1);
  wb1 := FALSE;
  tolong := longint(wb1);
  WriteLn('wordbool->longint : value should be 0...',tolong);
+ if tolong <> 0 then 
+   halt(1);
 {$ifndef tp}
  bb1 := TRUE;
  toint64 :=int64(bb1);
  WriteLn('boolean->int64 : value should be 1...',toint64);
+ if toint64 <> 1 then 
+   halt(1);
  bb1 := FALSE;
  toint64 :=int64(bb1);
  WriteLn('boolean->int64 : value should be 0...',toint64);
+ if toint64 <> 0 then 
+   halt(1);
  wb1 := TRUE;
  toint64 :=int64(wb1);
  WriteLn('wordbool->int64 : value should be 1...',toint64);
+ if toint64 <> 1 then 
+   halt(1);
  wb1 := FALSE;
  toint64 :=int64(wb1);
  WriteLn('wordbool->int64 : value should be 0...',toint64);
+ if toint64 <> 0 then 
+   halt(1);
 {$endif}
  lb1 := TRUE;
  tobyte := byte(lb1);
  WriteLn('longbool->byte : value should be 1...',tobyte);
+ if tobyte <> 1 then 
+   halt(1);
  lb1 := FALSE;
  tobyte := byte(lb1);
  WriteLn('longbool->byte : value should be 0...',tobyte);
+ if tobyte <> 0 then 
+   halt(1);
  lb1 := TRUE;
  toword := word(lb1);
  WriteLn('longbool->word : value should be 1...',toword);
+ if toword <> 1 then 
+   halt(1);
  lb1 := FALSE;
  toword := word(lb1);
  WriteLn('longbool->word : value should be 0...',toword);
+ if toword <> 0 then 
+   halt(1);
  lb1 := TRUE;
  tolong := longint(lb1);
  WriteLn('longbool->longint : value should be 1...',tolong);
+ if tolong <> 1 then 
+   halt(1);
  lb1 := FALSE;
  tolong := longint(lb1);
  WriteLn('longbool->longint : value should be 0...',tolong);
+ if tolong <> 0 then 
+   halt(1);
  { left : LOC_REGISTER }
  { from : LOC_REFERENCE }
  wb1 := TRUE;
  bb2 := wb1;
  WriteLn('wordbool->boolean : value should be TRUE...',bb2);
+ if not bb2 then 
+   halt(1);
  wb1 := FALSE;
  bb2 := wb1;
  WriteLn('wordbool->boolean : value should be FALSE...',bb2);
+ if bb2 then 
+   halt(1);
  lb1 := TRUE;
  bb2 := lb1;
  WriteLn('longbool->boolean : value should be TRUE...',bb2);
+ if not bb2 then 
+   halt(1);
  lb1 := FALSE;
  bb2 := lb1;
  WriteLn('longbool->boolean : value should be FALSE...',bb2);
+ if bb2 then 
+   halt(1);
  bb1 := TRUE;
  lb2 := bb1;
  WriteLn('boolean->longbool : value should be TRUE...',lb2);
+ if not lb2 then 
+   halt(1);
  bb1 := FALSE;
  lb2 := bb1;
  WriteLn('boolean->longbool : value should be FALSE...',lb2);
+ if lb2 then 
+   halt(1);
  { left : LOC_REGISTER }
  { from : LOC_JUMP     }
  WriteLn('Testing LOC_JUMP...');
@@ -130,35 +186,51 @@ begin
  tobyte := 1;
  tobyte:=byte(toword > tobyte);
  WriteLn('value should be 0...',tobyte);
+ if tobyte <> 0 then 
+   halt(1);
  toword := 2;
  tobyte := 1;
  tobyte:=byte(toword > tobyte);
  WriteLn('value should be 1...',tobyte);
+ if tobyte <> 1 then 
+   halt(1);
  toword := 0;
  tobyte := 1;
  toword:=word(toword > tobyte);
  WriteLn('value should be 0...',toword);
+ if toword <> 0 then 
+   halt(1);
  toword := 2;
  tobyte := 1;
  toword:=word(toword > tobyte);
  WriteLn('value should be 1...',toword);
+ if toword <> 1 then 
+   halt(1);
  toword := 0;
  tobyte := 1;
  tolong:=longint(toword > tobyte);
  WriteLn('value should be 0...',tolong);
+ if tolong <> 0 then 
+   halt(1);
  toword := 2;
  tobyte := 1;
  tolong:=longint(toword > tobyte);
  WriteLn('value should be 1...',tolong);
+ if tolong <> 1 then 
+   halt(1);
 {$ifndef tp}
  toword := 0;
  tobyte := 1;
  toint64:=int64(toword > tobyte);
  WriteLn('value should be 0...',toint64);
+ if toint64 <> 0 then 
+   halt(1);
  toword := 2;
  tobyte := 1;
  toint64:=int64(toword > tobyte);
  WriteLn('value should be 1...',toint64);
+ if toint64 <> 1 then 
+   halt(1);
 {$endif}
  { left : LOC_REGISTER }
  { from : LOC_FLAGS     }
@@ -167,40 +239,60 @@ begin
  bb1 := FALSE;
  bb1 := (wb1 > bb1);
  WriteLn('Value should be TRUE...',bb1);
+ if not bb1 then 
+   halt(1);
  wb1 := FALSE;
  bb1 := FALSE;
  bb1 := (wb1 > bb1);
  WriteLn('Value should be FALSE...',bb1);
+ if bb1 then 
+   halt(1);
  lb1 := TRUE;
  bb1 := FALSE;
  bb1 := (bb1 > lb1);
  WriteLn('Value should be FALSE...',bb1);
+ if bb1 then 
+   halt(1);
  lb1 := FALSE;
  bb1 := TRUE;
  bb1 := (bb1 > lb1);
  WriteLn('Value should be TRUE...',bb1);
+ if not bb1 then 
+   halt(1);
  lb1 := TRUE;
  bb1 := FALSE;
  wb1 := (bb1 > lb1);
  WriteLn('Value should be FALSE...',wb1);
+ if wb1 then 
+   halt(1);
  lb1 := FALSE;
  bb1 := TRUE;
  wb1 := (bb1 > lb1);
  WriteLn('Value should be TRUE...',wb1);
+ if not wb1 then 
+   halt(1);
  lb1 := TRUE;
  bb1 := FALSE;
  lb1 := (bb1 > lb1);
  WriteLn('Value should be FALSE...',lb1);
+ if lb1 then 
+   halt(1);
  lb1 := FALSE;
  bb1 := TRUE;
  lb1 := (bb1 > lb1);
  WriteLn('Value should be TRUE...',lb1);
+ if not lb1 then 
+   halt(1);
  bb1 := TRUE;
  bb2 := FALSE;
  lb1 := (bb1 > bb2);
  WriteLn('Value should be TRUE...',lb1);
+ if not lb1 then 
+   halt(1);
  bb1 := FALSE;
  bb2 := TRUE;
  lb1 := (bb1 > bb2);
  WriteLn('Value should be FALSE...',lb1);
+ if lb1 then 
+   halt(1);
 end.