Răsfoiți Sursa

+ tcgtypeconvnode.second_class_to_intf supports LOC_CONSTANT as well, resolves #31596

git-svn-id: trunk@35655 -
florian 8 ani în urmă
părinte
comite
0cf5ef459d
3 a modificat fișierele cu 23 adăugiri și 0 ștergeri
  1. 1 0
      .gitattributes
  2. 5 0
      compiler/ncgcnv.pas
  3. 17 0
      tests/webtbs/tw31596.pp

+ 1 - 0
.gitattributes

@@ -15411,6 +15411,7 @@ tests/webtbs/tw3143.pp svneol=native#text/plain
 tests/webtbs/tw31431.pp svneol=native#text/pascal
 tests/webtbs/tw3144.pp svneol=native#text/plain
 tests/webtbs/tw3157.pp svneol=native#text/plain
+tests/webtbs/tw31596.pp svneol=native#text/pascal
 tests/webtbs/tw3160a.pp svneol=native#text/plain
 tests/webtbs/tw3160b.pp svneol=native#text/plain
 tests/webtbs/tw3160c.pp svneol=native#text/plain

+ 5 - 0
compiler/ncgcnv.pas

@@ -736,6 +736,11 @@ interface
               begin
                 location.register:=left.location.register;
                 hlcg.g_ptrtypecast_reg(current_asmdata.CurrAsmList,left.resultdef,resultdef,location.register);
+              end;
+            LOC_CONSTANT:
+              begin
+                 location.register:=hlcg.getaddressregister(current_asmdata.CurrAsmList,resultdef);
+                 hlcg.a_load_const_reg(current_asmdata.CurrAsmList,resultdef,left.location.value,location.register);
               end
             else
               internalerror(121120001);

+ 17 - 0
tests/webtbs/tw31596.pp

@@ -0,0 +1,17 @@
+{ %norun }
+var
+
+ offset : Integer;
+ o      : TObject;
+
+begin
+
+ // OK
+ o := TObject(1);
+
+ offset := PtrInt(IInterface(TInterfacedObject(o))) - 1;
+ //
+
+ // project1.lpr(17,19) Error: Internal error 121120001
+ offset := PtrInt(IInterface(TInterfacedObject(1))) - 1;
+end.