Explorar o código

Fix for Mantis #25210 .

compiler/pdecobj.pas, object_dec:
  * since revision 25518 the global symtable of the current module is no longer popped and pushed again so that the defaware symtablestack can add the helper; thus we need to do this not only for static symtables, but for global ones as well
  * adjusted comment to reflect current situation

git-svn-id: trunk@25834 -
svenbarth %!s(int64=11) %!d(string=hai) anos
pai
achega
d91d4afb0f
Modificáronse 3 ficheiros con 33 adicións e 4 borrados
  1. 1 0
      .gitattributes
  2. 4 4
      compiler/pdecobj.pas
  3. 28 0
      tests/webtbs/tw25210.pp

+ 1 - 0
.gitattributes

@@ -13624,6 +13624,7 @@ tests/webtbs/tw25081.pp svneol=native#text/pascal
 tests/webtbs/tw25101.pp svneol=native#text/pascal
 tests/webtbs/tw2514.pp svneol=native#text/plain
 tests/webtbs/tw25198.pp svneol=native#text/plain
+tests/webtbs/tw25210.pp svneol=native#text/pascal
 tests/webtbs/tw2525.pp svneol=native#text/plain
 tests/webtbs/tw2536.pp svneol=native#text/plain
 tests/webtbs/tw2540.pp svneol=native#text/plain

+ 4 - 4
compiler/pdecobj.pas

@@ -1565,9 +1565,9 @@ implementation
         else if is_objcclass(current_structdef) then
           setobjcclassmethodoptions;
 
-        { if this helper is defined in the implementation section of the unit
-          or inside the main project file, the extendeddefs list of the current
-          module must be updated (it will be removed when poping the symtable) }
+        { we need to add this helper to the extendeddefs of the current module,
+          as the global and static symtable are not pushed onto the symtable
+          stack again (it will be removed when poping the symtable) }
         if is_objectpascal_helper(current_structdef) and
             (current_objectdef.extendeddef.typ<>errordef) then
           begin
@@ -1575,7 +1575,7 @@ implementation
             st:=current_structdef.owner;
             while st.symtabletype in [objectsymtable,recordsymtable] do
               st:=st.defowner.owner;
-            if st.symtabletype=staticsymtable then
+            if st.symtabletype in [staticsymtable,globalsymtable] then
               begin
                 if current_objectdef.extendeddef.typ in [recorddef,objectdef] then
                   s:=make_mangledname('',tabstractrecorddef(current_objectdef.extendeddef).symtable,'')

+ 28 - 0
tests/webtbs/tw25210.pp

@@ -0,0 +1,28 @@
+unit tw25210;
+
+{$mode objfpc}
+
+interface
+
+uses
+  Classes;
+
+type
+  TStringsHelper = class helper for TStrings
+    procedure Test;
+  end;
+
+implementation
+
+procedure TStringsHelper.Test;
+begin
+  Writeln('Foobar');
+end;
+
+var
+  s: TStrings;
+initialization
+  s := TStringList.Create;
+  s.Test;
+  s.Free;
+end.