From 0cf5ef459dc0a7734ff9a76197a2704ebe93d080 Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 25 Mar 2017 10:27:29 +0000 Subject: [PATCH] + tcgtypeconvnode.second_class_to_intf supports LOC_CONSTANT as well, resolves #31596 git-svn-id: trunk@35655 - --- .gitattributes | 1 + compiler/ncgcnv.pas | 5 +++++ tests/webtbs/tw31596.pp | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 tests/webtbs/tw31596.pp diff --git a/.gitattributes b/.gitattributes index 0631eaee55..1c10d2422f 100644 --- a/.gitattributes +++ b/.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 diff --git a/compiler/ncgcnv.pas b/compiler/ncgcnv.pas index 6dca127543..7df651a5ed 100644 --- a/compiler/ncgcnv.pas +++ b/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); diff --git a/tests/webtbs/tw31596.pp b/tests/webtbs/tw31596.pp new file mode 100644 index 0000000000..1eaa53e50a --- /dev/null +++ b/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.