Sfoglia il codice sorgente

compiler: allow to skip the 'static' modifier in the method implementation + modified test

git-svn-id: trunk@14578 -
paul 15 anni fa
parent
commit
58c71c3c59
2 ha cambiato i file con 19 aggiunte e 2 eliminazioni
  1. 18 1
      compiler/pdecsub.pas
  2. 1 1
      tests/test/tstatic1.pp

+ 18 - 1
compiler/pdecsub.pas

@@ -1053,7 +1053,7 @@ implementation
               consume(_PROCEDURE);
               if parse_proc_head(aclass,potype_procedure,pd) then
                 begin
-                  { pd=nil when it is a interface mapping }
+                  { pd=nil when it is an interface mapping }
                   if assigned(pd) then
                     begin
                       pd.returndef:=voidtype;
@@ -2694,6 +2694,7 @@ const
         po_comp : tprocoptions;
         paracompopt: tcompare_paras_options;
         forwardfound : boolean;
+        symentry: TSymEntry;
       begin
         forwardfound:=false;
 
@@ -2767,6 +2768,22 @@ const
                         end;
                     end;
 
+                   { Check static }
+                   if (po_staticmethod in fwpd.procoptions) then
+                    begin
+                      if not (po_staticmethod in currpd.procoptions) then
+                       begin
+                         include(currpd.procoptions, po_staticmethod);
+                         { remove self from the hidden paras }
+                         symentry:=currpd.parast.Find('self');
+                         if symentry<>nil then
+                          begin
+                            currpd.parast.Delete(symentry);
+                            currpd.calcparas;
+                          end;
+                       end;
+                    end;
+
                    { Check if the procedure type and return type are correct,
                      also the parameters must match also with the type }
                    if ((m_repeat_forward in current_settings.modeswitches) or

+ 1 - 1
tests/test/tstatic1.pp

@@ -21,7 +21,7 @@ begin
 end;
 
 // for now fpc requires 'static' modifiers also in the class implementation
-class procedure TSomeClass.SomeStaticMethod(A: Integer); {$ifdef fpc} static; {$endif}
+class procedure TSomeClass.SomeStaticMethod(A: Integer);
 begin
   WriteLn('TSomeClass.SomeStaticMethod: ', A);
   WriteLn('TSomeClass.FSomethingStatic: ', FSomethingStatic);