Browse Source

* always call procvars inside varargs in TP/Delphi mode (mantis #15446)

git-svn-id: trunk@14527 -
Jonas Maebe 15 years ago
parent
commit
b4c572483b
3 changed files with 31 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 4 0
      compiler/ncnv.pas
  3. 26 0
      tests/webtbs/tw15446.pp

+ 1 - 0
.gitattributes

@@ -10166,6 +10166,7 @@ tests/webtbs/tw15377.pp svneol=native#text/pascal
 tests/webtbs/tw1539.pp svneol=native#text/plain
 tests/webtbs/tw1539.pp svneol=native#text/plain
 tests/webtbs/tw15391.pp svneol=native#text/plain
 tests/webtbs/tw15391.pp svneol=native#text/plain
 tests/webtbs/tw15415.pp svneol=native#text/plain
 tests/webtbs/tw15415.pp svneol=native#text/plain
+tests/webtbs/tw15446.pp svneol=native#text/plain
 tests/webtbs/tw15453a.pp svneol=native#text/plain
 tests/webtbs/tw15453a.pp svneol=native#text/plain
 tests/webtbs/tw1567.pp svneol=native#text/plain
 tests/webtbs/tw1567.pp svneol=native#text/plain
 tests/webtbs/tw1573.pp svneol=native#text/plain
 tests/webtbs/tw1573.pp svneol=native#text/plain

+ 4 - 0
compiler/ncnv.pas

@@ -562,6 +562,10 @@ implementation
 
 
     procedure insert_varargstypeconv(var p : tnode; iscvarargs: boolean);
     procedure insert_varargstypeconv(var p : tnode; iscvarargs: boolean);
       begin
       begin
+        { procvars without arguments in variant arrays are always called by
+          Delphi }
+        if not(iscvarargs) then
+          maybe_call_procvar(p,true);
         if not(iscvarargs) and
         if not(iscvarargs) and
            (p.nodetype=stringconstn) then
            (p.nodetype=stringconstn) then
           p:=ctypeconvnode.create_internal(p,cansistringtype)
           p:=ctypeconvnode.create_internal(p,cansistringtype)

+ 26 - 0
tests/webtbs/tw15446.pp

@@ -0,0 +1,26 @@
+program varfunc_test;
+
+{$IFDEF FPC}
+  {$mode Delphi}
+{$ELSE}
+  {$APPTYPE CONSOLE}
+{$ENDIF}
+{$H+}
+
+uses sysutils;
+
+function TestFunc1 : Longint;
+begin
+  Result := 100;
+end;
+
+Type Tfunc1 = function : Longint;
+var
+  TestFunc2 : Tfunc1 = TestFunc1;
+
+begin
+  writeln({$IFDEF FPC}'FPC'{$ELSE}'Delphi'{$ENDIF});
+
+  writeln( Format('%d',[TestFunc1]) );
+  writeln( Format('%d',[TestFunc2]) ); 
+end.