Ver código fonte

Merged revisions 706-708 via svnmerge from
/trunk

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

peter 20 anos atrás
pai
commit
0f1a5c4ae3
4 arquivos alterados com 74 adições e 2 exclusões
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/ncnv.pas
  3. 9 1
      compiler/nflw.pas
  4. 59 0
      tests/webtbs/tw4007.pp

+ 1 - 0
.gitattributes

@@ -5960,6 +5960,7 @@ tests/webtbs/tw3971.pp svneol=native#text/plain
 tests/webtbs/tw3973.pp svneol=native#text/plain
 tests/webtbs/tw3977.pp svneol=native#text/plain
 tests/webtbs/tw3977.txt svneol=native#text/plain
+tests/webtbs/tw4007.pp svneol=native#text/plain
 tests/webtbs/tw4009.pp svneol=native#text/plain
 tests/webtbs/tw4010.pp svneol=native#text/plain
 tests/webtbs/tw4013.pp svneol=native#text/plain

+ 5 - 1
compiler/ncnv.pas

@@ -366,8 +366,12 @@ implementation
                  p3:=nil;
                end;
               resulttypepass(p2);
+              set_varstate(p2,vs_used,[vsf_must_be_valid]);
               if assigned(p3) then
-               resulttypepass(p3);
+                begin
+                  resulttypepass(p3);
+                  set_varstate(p3,vs_used,[vsf_must_be_valid]);
+                end;
               if codegenerror then
                break;
               case p2.resulttype.def.deftype of

+ 9 - 1
compiler/nflw.pas

@@ -216,7 +216,7 @@ implementation
       globtype,systems,
       cutils,verbose,globals,
       symconst,paramgr,defcmp,defutil,htypechk,pass_1,
-      ncal,nadd,ncon,nmem,nld,ncnv,nbas,cgobj,
+      ncal,nadd,ncon,nmem,nld,ncnv,nbas,cgobj,nutils,
     {$ifdef state_tracking}
       nstate,
     {$endif}
@@ -353,6 +353,10 @@ implementation
          resulttype:=voidtype;
 
          resulttypepass(left);
+
+         { tp procvar support }
+         maybe_call_procvar(left,true);
+
          {A not node can be removed.}
          if left.nodetype=notn then
             begin
@@ -534,6 +538,10 @@ implementation
          resulttype:=voidtype;
 
          resulttypepass(left);
+
+         { tp procvar support }
+         maybe_call_procvar(left,true);
+
          { if path }
          if assigned(right) then
            resulttypepass(right);

+ 59 - 0
tests/webtbs/tw4007.pp

@@ -0,0 +1,59 @@
+{ Source provided for Free Pascal Bug Report 4007 }
+{ Submitted by "Torsten Kildal" on  2005-05-23 }
+{ e-mail: [email protected] }
+PROGRAM H;
+{$IFDEF FPC} {$MODE TP} {$ENDIF}
+
+VAR
+  Handler: function: boolean;
+
+  function AHandler: boolean; far;
+  begin
+    AHandler:=true;
+  end;
+
+begin
+  Handler:= AHandler;
+
+  {here FPC differs from BP ->BUG}
+  if Handler then writeln('1');
+  {BP7 : '1'}
+  {1010: '1'}
+  {19x : Boolean expression expected, but got "<procedure variable type of function:Boolean;Register>"}
+  {200 : Boolean expression expected, but got "<procedure variable type of function:Boolean;Register>"}
+
+  {the same with "=true" shows no difference -> conflict to '1'}
+  if Handler=true then writeln('2');
+  {BP7 : '2'}
+  {1010: '2'}
+  {19x : '2'}
+  {200 : '2'}
+
+  {here FPC differs from BP again -> BUG}
+  if Handler() then writeln('3');
+  {BP7 : THEN expected}
+  {1010: '3'}
+  {19x : '3'}
+  {200 : '3'}
+
+{$ifdef nok}
+  {this both BP and FPC don't like -> ok}
+  if Handler=NIL then writeln('4');
+  {BP7 : Type Mismatch}
+  {1010: Operator is not overloaded}
+  {19x : Incompatible types: got "Boolean" expected "LongInt"}
+  {200 : Incompatible types: got "Boolean" expected "LongInt"}
+{$endif nok}
+
+  {the rest is accepted by both BP and FPC -> ok}
+  if @Handler<>NIL     then writeln('5');
+  if assigned(Handler) then writeln('6');
+
+end.
+
+(*
+  "BP7"  = Borland Pascal 7.0       -> 1,2,    5,6
+  "1010" = FPC 1.0.10               -> 1,2,3,  5,6
+  "19x"  = FPC 1.9.4 / 1.9.6        ->   2,3,  5,6
+  "200"  = FPC 2.0.0                ->   2,3,  5,6
+*)