From 5efb32285aa0a25a298b0c9540e48622ac8bc7a8 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 9 Oct 2016 12:34:01 +0000 Subject: [PATCH] * fixed alignment for interface RTTI (patch by Alfred, mantis #30182) git-svn-id: trunk@34695 - --- .gitattributes | 1 + compiler/ncgrtti.pas | 8 +++++--- tests/webtbs/tw30182.pp | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 tests/webtbs/tw30182.pp diff --git a/.gitattributes b/.gitattributes index 32a1f1ec7b..b8c8803136 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15205,6 +15205,7 @@ tests/webtbs/tw30119b.pp svneol=native#text/pascal tests/webtbs/tw3012.pp svneol=native#text/plain tests/webtbs/tw30166.pp svneol=native#text/plain tests/webtbs/tw30179.pp svneol=native#text/pascal +tests/webtbs/tw30182.pp svneol=native#text/plain tests/webtbs/tw30202.pp svneol=native#text/pascal tests/webtbs/tw30203.pp svneol=native#text/pascal tests/webtbs/tw30207.pp svneol=native#text/plain diff --git a/compiler/ncgrtti.pas b/compiler/ncgrtti.pas index 4d117ddddc..c4e335e8f1 100644 --- a/compiler/ncgrtti.pas +++ b/compiler/ncgrtti.pas @@ -1096,6 +1096,10 @@ implementation propnamelist:=TFPHashObjectList.Create; collect_propnamelist(propnamelist,def); + tcb.begin_anonymous_record('',defaultpacking,reqalign, + targetinfos[target_info.system]^.alignment.recordalignmin, + targetinfos[target_info.system]^.alignment.maxCrecordalign); + { write parent typeinfo } write_rtti_reference(tcb,def.childof,fullrtti); @@ -1112,10 +1116,8 @@ implementation { ifDispatch, } tcb.emit_ord_const(IntfFlags,u8inttype); - tcb.begin_anonymous_record('',defaultpacking,reqalign, - targetinfos[target_info.system]^.alignment.recordalignmin, - targetinfos[target_info.system]^.alignment.maxCrecordalign); + { write GUID } tcb.emit_guid_const(def.iidguid^); { write unit name } diff --git a/tests/webtbs/tw30182.pp b/tests/webtbs/tw30182.pp new file mode 100644 index 0000000000..3a4467fd2c --- /dev/null +++ b/tests/webtbs/tw30182.pp @@ -0,0 +1,33 @@ +program SmallTestInterfaceRTTI; + +{$mode objfpc}{$H+} + +uses + classes, typinfo; + +type + IMyNewMPInterface = interface(IInvokable) + ['{AA503475-0187-4108-8E27-41475F4EF818}'] + procedure TestStdCall(LongParaName: TObject; const B: string; var C: integer; out D: byte); stdcall; + end; + +var + ti:PTypeInfo; + td : PTypeData; +begin + ti:=TypeInfo(IMyNewMPInterface); + + td := GetTypeData(ti); + + // this gives an error (e.g. wrong data) on aarch64. + // after patch of ncgrtti.pas, data is correct (unit name) + if ti^.Kind = tkInterface then + begin + writeln('IntfUnit: ',td^.IntfUnit); + if td^.IntfUnit<>'SmallTestInterfaceRTTI' then + halt(1); + end + else + halt(2); +end. +