Procházet zdrojové kódy

* don't give an internal error when creating a dynamic array or a
record that requires init/finalisation with an objcclass
(mantis #16366)

git-svn-id: trunk@15202 -

Jonas Maebe před 15 roky
rodič
revize
0b44f8db1f
3 změnil soubory, kde provedl 31 přidání a 0 odebrání
  1. 1 0
      .gitattributes
  2. 9 0
      compiler/symdef.pas
  3. 21 0
      tests/webtbs/tw16366.pp

+ 1 - 0
.gitattributes

@@ -10350,6 +10350,7 @@ tests/webtbs/tw16311.pp svneol=native#text/plain
 tests/webtbs/tw16326.pp svneol=native#text/plain
 tests/webtbs/tw16328.pp svneol=native#text/plain
 tests/webtbs/tw1634.pp svneol=native#text/plain
+tests/webtbs/tw16366.pp svneol=native#text/plain
 tests/webtbs/tw1658.pp svneol=native#text/plain
 tests/webtbs/tw1677.pp svneol=native#text/plain
 tests/webtbs/tw1681.pp svneol=native#text/plain

+ 9 - 0
compiler/symdef.pas

@@ -4520,6 +4520,15 @@ implementation
           result:=inherited rtti_mangledname(rt)
         else
           begin
+            { necessary in case of a dynamic array of nsobject, or
+              if an nsobject field appears in a record that needs
+              init/finalisation }
+            if rt=initrtti then
+              begin
+                result:=voidpointertype.rtti_mangledname(rt);
+                exit;
+              end;
+
             if not(target_info.system in systems_objc_nfabi) then
               begin
                 result:=target_asm.labelprefix;

+ 21 - 0
tests/webtbs/tw16366.pp

@@ -0,0 +1,21 @@
+{ %target=darwin }
+{ %cpu=powerpc,powerpc64,i386,x86_64,arm }
+
+{$mode objfpc}
+{$modeswitch objectivec1}
+
+type
+  ta = array of nsobject;
+var
+  a: ta;
+  i: longint;
+begin
+  setlength(a,5);
+  for i := low(a) to high(a) do
+    begin
+      if a[i]<>nil then
+        halt(1);
+      { crash if the rtl tries to "finalise" the nsobject elements }
+      a[i]:=nsobject(i*10000+12345);
+    end;
+end.