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

* don't trash reference counted types with -gt (mantis 8183)

git-svn-id: trunk@6149 -
Jonas Maebe 18 жил өмнө
parent
commit
fcb128c66c

+ 1 - 0
.gitattributes

@@ -7991,6 +7991,7 @@ tests/webtbs/tw8150a.pp svneol=native#text/plain
 tests/webtbs/tw8150d.pp svneol=native#text/plain
 tests/webtbs/tw8150d.pp svneol=native#text/plain
 tests/webtbs/tw8155.pp svneol=native#text/plain
 tests/webtbs/tw8155.pp svneol=native#text/plain
 tests/webtbs/tw8156.pp svneol=native#text/plain
 tests/webtbs/tw8156.pp svneol=native#text/plain
+tests/webtbs/tw8183.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/uw0555.pp svneol=native#text/plain
 tests/webtbs/uw0555.pp svneol=native#text/plain

+ 6 - 4
compiler/ncgutil.pas

@@ -963,9 +963,10 @@ implementation
         trashintval: aint;
         trashintval: aint;
         list: TAsmList absolute arg;
         list: TAsmList absolute arg;
       begin
       begin
-        if (tsym(p).typ=localvarsym) or
-           ((tsym(p).typ=paravarsym) and
-            (vo_is_funcret in tparavarsym(p).varoptions))  then
+        if ((tsym(p).typ=localvarsym) or
+            ((tsym(p).typ=paravarsym) and
+             (vo_is_funcret in tparavarsym(p).varoptions))) and
+           not(tabstractnormalvarsym(p).vardef.needs_inittable) then
          begin
          begin
            trashintval := trashintvalues[localvartrashing];
            trashintval := trashintvalues[localvartrashing];
            case tabstractnormalvarsym(p).initialloc.loc of
            case tabstractnormalvarsym(p).initialloc.loc of
@@ -1140,7 +1141,6 @@ implementation
         if (tsym(p).typ=paravarsym) then
         if (tsym(p).typ=paravarsym) then
          begin
          begin
            needs_inittable :=
            needs_inittable :=
-             not is_class_or_interface(tparavarsym(p).vardef) and
              tparavarsym(p).vardef.needs_inittable;
              tparavarsym(p).vardef.needs_inittable;
            case tparavarsym(p).varspez of
            case tparavarsym(p).varspez of
              vs_value :
              vs_value :
@@ -1158,6 +1158,7 @@ implementation
                      cg.a_load_loc_reg(list,OS_ADDR,tparavarsym(p).initialloc,tmpreg);
                      cg.a_load_loc_reg(list,OS_ADDR,tparavarsym(p).initialloc,tmpreg);
                      reference_reset_base(href,tmpreg,0);
                      reference_reset_base(href,tmpreg,0);
                      if (localvartrashing <> -1) and
                      if (localvartrashing <> -1) and
+                        not(needs_inittable) and
                         { needs separate implementation to trash open arrays }
                         { needs separate implementation to trash open arrays }
                         { since their size is only known at run time         }
                         { since their size is only known at run time         }
                         not is_special_array(tparavarsym(p).vardef) then
                         not is_special_array(tparavarsym(p).vardef) then
@@ -1167,6 +1168,7 @@ implementation
                    end;
                    end;
                end;
                end;
              else if (localvartrashing <> -1) and
              else if (localvartrashing <> -1) and
+                     not(needs_inittable) and
                      ([vo_is_funcret,vo_is_hidden_para] * tparavarsym(p).varoptions = [vo_is_funcret,vo_is_hidden_para]) then
                      ([vo_is_funcret,vo_is_hidden_para] * tparavarsym(p).varoptions = [vo_is_funcret,vo_is_hidden_para]) then
                    begin
                    begin
                      tmpreg:=cg.getaddressregister(list);
                      tmpreg:=cg.getaddressregister(list);

+ 21 - 0
tests/webtbs/tw8183.pp

@@ -0,0 +1,21 @@
+{ %opt=-gt }
+
+program test;
+
+{$MODE OBJFPC}
+
+type
+  xstr = interface(iunknown) end;
+
+operator := (a: integer): xstr;
+begin
+  if ptruint(result) <> ptruint(nil) then
+    halt(1);
+  pointer(result) := nil;
+end;
+
+var
+  x: xstr;
+begin
+  x := 42;
+end.