Browse Source

--- Merging r29450 into '.':
U compiler/ncgutil.pas
--- Merging r29452 into '.':
A tests/webtbs/tw27294.pp
A tests/webtbs/uw27294.pp

# revisions: 29450,29452

git-svn-id: branches/fixes_3_0@29510 -

marco 10 năm trước cách đây
mục cha
commit
3498ae9f06
4 tập tin đã thay đổi với 68 bổ sung4 xóa
  1. 2 0
      .gitattributes
  2. 12 4
      compiler/ncgutil.pas
  3. 26 0
      tests/webtbs/tw27294.pp
  4. 28 0
      tests/webtbs/uw27294.pp

+ 2 - 0
.gitattributes

@@ -14190,6 +14190,7 @@ tests/webtbs/tw2725.pp svneol=native#text/plain
 tests/webtbs/tw2727.pp svneol=native#text/plain
 tests/webtbs/tw2728.pp svneol=native#text/plain
 tests/webtbs/tw2729.pp svneol=native#text/plain
+tests/webtbs/tw27294.pp svneol=native#text/plain
 tests/webtbs/tw2730.pp svneol=native#text/plain
 tests/webtbs/tw2731.pp svneol=native#text/plain
 tests/webtbs/tw2736.pp svneol=native#text/plain
@@ -14933,6 +14934,7 @@ tests/webtbs/uw26922a.pp svneol=native#text/pascal
 tests/webtbs/uw26922b.pp svneol=native#text/pascal
 tests/webtbs/uw2706a.pp svneol=native#text/plain
 tests/webtbs/uw2706b.pp svneol=native#text/plain
+tests/webtbs/uw27294.pp svneol=native#text/plain
 tests/webtbs/uw2731.pp svneol=native#text/plain
 tests/webtbs/uw2738.pp svneol=native#text/plain
 tests/webtbs/uw2834.pp svneol=native#text/plain

+ 12 - 4
compiler/ncgutil.pas

@@ -1348,10 +1348,18 @@ implementation
         item := TCmdStrListItem(pd.aliasnames.first);
         while assigned(item) do
           begin
-            current_asmdata.DefineAsmSymbol(item.str,AB_GLOBAL,AT_FUNCTION);
-            item := TCmdStrListItem(item.next);
-          end;
-       end;
+            { The condition to use global or local symbol must match
+              the code written in hlcg.gen_proc_symbol to 
+              avoid change from AB_LOCAL to AB_GLOBAL, which generates
+              erroneous code (at least for targets using GOT) } 
+            if (cs_profile in current_settings.moduleswitches) or
+               (po_global in current_procinfo.procdef.procoptions) then
+              current_asmdata.DefineAsmSymbol(item.str,AB_GLOBAL,AT_FUNCTION)
+            else
+              current_asmdata.DefineAsmSymbol(item.str,AB_LOCAL,AT_FUNCTION);
+           item := TCmdStrListItem(item.next);
+         end;
+      end;
 
 
     procedure gen_proc_entry_code(list:TAsmList);

+ 26 - 0
tests/webtbs/tw27294.pp

@@ -0,0 +1,26 @@
+uses
+  uw27294;
+
+var
+  p : procedure;
+
+procedure test;
+
+begin
+  p:=@test;
+  writeln('OK');
+end;
+
+procedure global;
+begin
+  p:=nil;
+  test;
+  p();
+end;
+
+begin
+  global;
+  uw27294.global;
+end.
+
+

+ 28 - 0
tests/webtbs/uw27294.pp

@@ -0,0 +1,28 @@
+unit
+  uw27294;
+
+interface
+
+procedure global;
+
+implementation
+
+var
+  p : procedure;
+
+procedure test;
+
+begin
+  p:=@test;
+  writeln('OK');
+end;
+
+procedure global;
+begin
+  p:=nil;
+  test;
+  p();
+end;
+
+end.
+