Browse Source

* don't generate a hidden parameter for static class methods, resolves #10998

git-svn-id: trunk@10876 -
florian 17 years ago
parent
commit
95c69a64ad
3 changed files with 24 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 5 0
      compiler/pdecsub.pas
  3. 18 0
      tests/webtbs/tw10998.pp

+ 1 - 0
.gitattributes

@@ -8138,6 +8138,7 @@ tests/webtbs/tw1096.pp svneol=native#text/plain
 tests/webtbs/tw10966.pp svneol=native#text/plain
 tests/webtbs/tw1097.pp svneol=native#text/plain
 tests/webtbs/tw10979.pp svneol=native#text/plain
+tests/webtbs/tw10998.pp svneol=native#text/plain
 tests/webtbs/tw11006.pp svneol=native#text/plain
 tests/webtbs/tw11027.pp svneol=native#text/plain
 tests/webtbs/tw1103.pp svneol=native#text/plain

+ 5 - 0
compiler/pdecsub.pas

@@ -165,6 +165,11 @@ implementation
                 assigned(tprocdef(pd)._class) and
                 (pd.parast.symtablelevel=normal_function_level) then
               begin
+                { static class methods have no hidden self/vmt pointer }
+                if (po_staticmethod in pd.procoptions) and
+                   (po_classmethod in pd.procoptions) then
+                   exit;
+
                 storepos:=current_tokenpos;
                 current_tokenpos:=tprocdef(pd).fileinfo;
 

+ 18 - 0
tests/webtbs/tw10998.pp

@@ -0,0 +1,18 @@
+program statictest;
+
+{$mode delphi}{$STATIC ON}
+
+type
+  TMyClass = class
+  public
+    class procedure StaticCall; static;
+  end;
+
+class procedure TMyClass.StaticCall;
+begin
+  WriteLn('Static method was called!');
+end;
+
+begin
+  TMyClass.StaticCall;
+end.