Explorar el Código

* type casting could force class variables into sub registers, so handle them in subscript nodes as well

git-svn-id: trunk@23587 -
florian hace 12 años
padre
commit
77bbb8b5bc
Se han modificado 3 ficheros con 24 adiciones y 1 borrados
  1. 1 0
      .gitattributes
  2. 6 1
      compiler/ncgmem.pas
  3. 17 0
      tests/tbs/tb0592.pp

+ 1 - 0
.gitattributes

@@ -9784,6 +9784,7 @@ tests/tbs/tb0588.pp svneol=native#text/pascal
 tests/tbs/tb0589.pp svneol=native#text/pascal
 tests/tbs/tb0590.pp svneol=native#text/pascal
 tests/tbs/tb0591.pp svneol=native#text/pascal
+tests/tbs/tb0592.pp svneol=native#text/plain
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain

+ 6 - 1
compiler/ncgmem.pas

@@ -324,7 +324,12 @@ implementation
                           location.reference.base := left.location.register;
                       end;
                     LOC_CREFERENCE,
-                    LOC_REFERENCE:
+                    LOC_REFERENCE,
+                    { tricky type casting of parameters can cause these locations, see tb0592.pp on x86_64-linux }
+                    LOC_SUBSETREG,
+                    LOC_CSUBSETREG,
+                    LOC_SUBSETREF,
+                    LOC_CSUBSETREF:
                       begin
                          location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList);
                          hlcg.a_load_loc_reg(current_asmdata.CurrAsmList,left.resultdef,left.resultdef,left.location,location.reference.base);

+ 17 - 0
tests/tbs/tb0592.pp

@@ -0,0 +1,17 @@
+{$mode objfpc}
+type 
+  TT_Stream   = record z : Pointer; end;
+
+  TFreeTypeStream = class
+    FUsed : Boolean;
+  end;
+
+ procedure TT_Done_Stream( stream : TT_Stream );
+ begin
+   if stream.z = nil then exit;
+   TFreeTypeStream(stream.z).FUsed := false;
+ end;
+
+
+begin
+end.