2
0
Эх сурвалжийг харах

* detect static data use by record methods and methods of nested classes/
records, so we avoid inlining them (mantis #25598)

git-svn-id: trunk@26617 -

Jonas Maebe 11 жил өмнө
parent
commit
c05da62b0e

+ 2 - 0
.gitattributes

@@ -13796,6 +13796,7 @@ tests/webtbs/tw2536.pp svneol=native#text/plain
 tests/webtbs/tw25361.pp svneol=native#text/plain
 tests/webtbs/tw2540.pp svneol=native#text/plain
 tests/webtbs/tw25551.pp svneol=native#text/plain
+tests/webtbs/tw25598.pp svneol=native#text/plain
 tests/webtbs/tw2561.pp svneol=native#text/plain
 tests/webtbs/tw2588.pp svneol=native#text/plain
 tests/webtbs/tw2589.pp svneol=native#text/plain
@@ -14572,6 +14573,7 @@ tests/webtbs/uw25059.pp svneol=native#text/pascal
 tests/webtbs/uw25059.test.pp svneol=native#text/pascal
 tests/webtbs/uw25059.withdot.pp svneol=native#text/pascal
 tests/webtbs/uw25132.pp svneol=native#text/pascal
+tests/webtbs/uw25598.pp svneol=native#text/plain
 tests/webtbs/uw2706a.pp svneol=native#text/plain
 tests/webtbs/uw2706b.pp svneol=native#text/plain
 tests/webtbs/uw2731.pp svneol=native#text/plain

+ 1 - 1
compiler/ncal.pas

@@ -3449,7 +3449,7 @@ implementation
             { Check if we can inline the procedure when it references proc/var that
               are not in the globally available }
             st:=procdefinition.owner;
-            if (st.symtabletype=ObjectSymtable) then
+            while (st.symtabletype in [ObjectSymtable,recordsymtable]) do
               st:=st.defowner.owner;
             if (pi_uses_static_symtable in tprocdef(procdefinition).inlininginfo^.flags) and
                (st.symtabletype=globalsymtable) and

+ 6 - 0
tests/webtbs/tw25598.pp

@@ -0,0 +1,6 @@
+uses uw25598;
+
+begin
+  TR.Foo; // Error: Undefined symbol: TC_$R03U01_$$_C
+end.
+

+ 22 - 0
tests/webtbs/uw25598.pp

@@ -0,0 +1,22 @@
+unit uw25598;
+
+{$mode delphi}
+
+interface
+
+type
+  TR = record
+    class function Foo: Integer; static; inline;
+  end;
+
+implementation
+
+const
+  C: array[0..0] of byte = (0);
+
+class function TR.Foo: Integer; inline;
+begin
+  Result := C[0];
+end;
+
+end.