Sfoglia il codice sorgente

Fix for Mantis #29372.

compiler/ncgcal.pas:
  * tchcallnode.release_para_temps: don't release temps of a constructor's self parameter

+ added test

git-svn-id: trunk@32990 -
svenbarth 9 anni fa
parent
commit
d2a7f17d8c
3 ha cambiato i file con 58 aggiunte e 1 eliminazioni
  1. 1 0
      .gitattributes
  2. 8 1
      compiler/ncgcal.pas
  3. 49 0
      tests/webtbs/tw29372.pp

+ 1 - 0
.gitattributes

@@ -14921,6 +14921,7 @@ tests/webtbs/tw2926.pp svneol=native#text/plain
 tests/webtbs/tw2927.pp svneol=native#text/plain
 tests/webtbs/tw29321.pp svneol=native#text/pascal
 tests/webtbs/tw29353.pp -text svneol=native#text/plain
+tests/webtbs/tw29372.pp svneol=native#text/pascal
 tests/webtbs/tw2942a.pp svneol=native#text/plain
 tests/webtbs/tw2942b.pp svneol=native#text/plain
 tests/webtbs/tw2943.pp svneol=native#text/plain

+ 8 - 1
compiler/ncgcal.pas

@@ -625,7 +625,14 @@ implementation
                begin
                  { don't release the funcret temp }
                  if not(assigned(ppn.parasym)) or
-                    not(vo_is_funcret in ppn.parasym.varoptions) then
+                    not(
+                      (vo_is_funcret in ppn.parasym.varoptions) or
+                      (
+                        (vo_is_self in ppn.parasym.varoptions) and
+                        (procdefinition.proctypeoption=potype_constructor) and
+                        (ppn.parasym.vardef.typ<>objectdef)
+                      )
+                    )then
                    location_freetemp(current_asmdata.CurrAsmList,ppn.left.location);
                  { process also all nodes of an array of const }
                  hp:=ppn.left;

+ 49 - 0
tests/webtbs/tw29372.pp

@@ -0,0 +1,49 @@
+program tw29372;
+
+{$MODE DELPHI}
+type
+  TR1 = record
+    A, B, C: Int64;
+    constructor Create(_A, _B, _C: Int64);
+  end;
+
+  TR2 = record
+    D, E, F: Int64;
+    constructor Create(_D, _E, _F: Int64);
+  end;
+
+  constructor TR1.Create(_A, _B, _C: Int64);
+  begin
+    A := _A;
+    B := _B;
+    C := _C;
+  end;
+
+  constructor TR2.Create(_D, _E, _F: Int64);
+  begin
+    D := _D;
+    E := _E;
+    F := _F;
+  end;
+
+{ Note: unlike in the file attached at #29372 we use "const" both times to
+        trigger the error on x86_64 as well }
+procedure Foo(const _1: TR1; const _2: TR2);
+begin
+  if _1.A <> 1 then
+    Halt(1);
+  if _1.B <> 2 then
+    Halt(2);
+  if _1.C <> 3 then
+    Halt(3);
+  if _2.D <> 4 then
+    Halt(2);
+  if _2.E <> 5 then
+    Halt(5);
+  if _2.F <> 6 then
+    Halt(6);
+end;
+
+begin
+  Foo(TR1.Create(1, 2, 3), TR2.Create(4,5,6));
+end.