From d13838ac0b8509eece4f43b7750bb9b33016f851 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Sun, 31 Jan 2021 21:23:29 +0000 Subject: [PATCH] + add a test which ensures that a "const TVarData" parameter is passed as a reference. This is required for Delphi compatibility as implementers of IVarInvokable or inheritors of TInvokableVariantType need to modify the variant data by using a pointer to the TVarData because it's passed as const and thus not modifyable by itself. This behavior is documented in so far as the C++ builder documentation shows that the same parameter is implemented as "const&". git-svn-id: trunk@48478 - --- .gitattributes | 1 + tests/test/cg/tpara4.pp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/test/cg/tpara4.pp diff --git a/.gitattributes b/.gitattributes index e42198ccdf..7bc7786e85 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13982,6 +13982,7 @@ tests/test/cg/tobjsize.pp svneol=native#text/plain tests/test/cg/tpara1.pp svneol=native#text/plain tests/test/cg/tpara2.pp svneol=native#text/plain tests/test/cg/tpara3.pp svneol=native#text/plain +tests/test/cg/tpara4.pp svneol=native#text/pascal tests/test/cg/tprintf.pp svneol=native#text/plain tests/test/cg/tprintf2.pp svneol=native#text/plain tests/test/cg/tprintf3.pp svneol=native#text/plain diff --git a/tests/test/cg/tpara4.pp b/tests/test/cg/tpara4.pp new file mode 100644 index 0000000000..f175a553eb --- /dev/null +++ b/tests/test/cg/tpara4.pp @@ -0,0 +1,22 @@ +{ This test ensures that a "const TVarData" parameter is passed as a reference. + This is required for Delphi compatibility as implementers of IVarInvokable or + inheritors of TInvokableVariantType need to modify the variant data by using + a pointer to the TVarData because it's passed as const and thus not modifyable + by itself. + This behavior is documented in so far as the C++ builder documentation shows + that the same parameter is implemented as "const&". } + +program tpara4; + +var + d: TVarData; + +procedure Test(const v: TVarData); +begin + if @d <> @v then + Halt(1); +end; + +begin + Test(d); +end.