Browse Source

* type casting could force pointers into sub registers, so handle them when converting the pointer to an array

git-svn-id: trunk@23591 -
florian 12 years ago
parent
commit
5a81601565
3 changed files with 57 additions and 3 deletions
  1. 1 0
      .gitattributes
  2. 9 3
      compiler/ncgcnv.pas
  3. 47 0
      tests/tbs/tb0593.pp

+ 1 - 0
.gitattributes

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

+ 9 - 3
compiler/ncgcnv.pas

@@ -349,12 +349,18 @@ interface
                 location.reference.base := left.location.register;
                 location.reference.base := left.location.register;
             end;
             end;
           LOC_REFERENCE,
           LOC_REFERENCE,
-          LOC_CREFERENCE :
+          LOC_CREFERENCE,
+          { tricky type casting of parameters can cause these locations, see tb0593.pp on x86_64-linux }
+          LOC_SUBSETREG,
+          LOC_CSUBSETREG,
+          LOC_SUBSETREF,
+          LOC_CSUBSETREF:
             begin
             begin
               location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList);
               location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList);
-              cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.reference,
+              hlcg.a_load_loc_reg(current_asmdata.CurrAsmList,left.resultdef,left.resultdef,left.location,
                 location.reference.base);
                 location.reference.base);
-              location_freetemp(current_asmdata.CurrAsmList,left.location);
+              if left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
+                location_freetemp(current_asmdata.CurrAsmList,left.location);
             end;
             end;
           else
           else
             internalerror(2002032216);
             internalerror(2002032216);

+ 47 - 0
tests/tbs/tb0593.pp

@@ -0,0 +1,47 @@
+{$mode objfpc}
+type
+  TBlockType = (
+    btNone,
+    btBegin,
+    btAsm,
+    btEdgedBracket,
+    btRoundBracket,
+    btTry,
+    btFinally,
+    btExcept,
+    btCase,
+    btCaseOf,
+    btCaseColon,
+    btCaseElse,
+    btRepeat,
+    btIf,
+    btIfElse,
+    btClass,
+    btInterface,
+    btObject,
+    btRecord
+    );
+  TBlock = record
+    Typ: TBlockType;
+    StartPos: integer;
+    InnerIndent: integer;
+    InnerStartPos: integer;
+  end;
+  PBlock = ^TBlock;
+  TBlockStack = record
+    Stack: PBlock;
+    Capacity: integer;
+    Top: integer;
+  end;
+
+
+function TopBlockType(const Stack: TBlockStack): TBlockType;
+  begin
+    if Stack.Top>=0 then
+      Result:=Stack.Stack[Stack.Top].Typ
+    else
+      Result:=btNone;
+  end;  
+
+begin
+end.