From 0127c72cb84ae0d5f417029040a706c2776ee2fc Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sat, 25 May 2024 20:59:21 +0200 Subject: [PATCH] Get rid of DMC workaround for the dll_cxx dshell test --- compiler/test/dshell/dll_cxx.d | 2 +- .../test/dshell/extra-files/dll_cxx/cppnew.d | 68 ------------------- .../test/dshell/extra-files/dll_cxx/testdll.d | 2 +- 3 files changed, 2 insertions(+), 70 deletions(-) delete mode 100644 compiler/test/dshell/extra-files/dll_cxx/cppnew.d diff --git a/compiler/test/dshell/dll_cxx.d b/compiler/test/dshell/dll_cxx.d index 0102e12793..827cc7506e 100644 --- a/compiler/test/dshell/dll_cxx.d +++ b/compiler/test/dshell/dll_cxx.d @@ -53,7 +53,7 @@ int main() // The arguments have to be passed as an array, because run would replace '/' with '\\' otherwise. run(dllCmd); - run(`$DMD -m$MODEL -I$SRC -g -od=$OUTPUT_BASE -of=$EXE_NAME $SRC/testdll.d $SRC/cppnew.d ` ~ mainExtra); + run(`$DMD -m$MODEL -g -od=$OUTPUT_BASE -of=$EXE_NAME $SRC/testdll.d ` ~ mainExtra); run(`$EXE_NAME`, stdout, stderr, [`LD_LIBRARY_PATH`: Vars.OUTPUT_BASE]); diff --git a/compiler/test/dshell/extra-files/dll_cxx/cppnew.d b/compiler/test/dshell/extra-files/dll_cxx/cppnew.d deleted file mode 100644 index 7d440077e3..0000000000 --- a/compiler/test/dshell/extra-files/dll_cxx/cppnew.d +++ /dev/null @@ -1,68 +0,0 @@ -module cppnew; - -/* This module contains copies from core.stdcpp.new_.d, but with - * modifications for DMC. */ - -T* cpp_new(T, Args...)(auto ref Args args) if (!is(T == class)) -{ - import core.lifetime : emplace, forward; - - T* mem = cast(T*)__cpp_new(T.sizeof); - return mem.emplace(forward!args); -} - -T cpp_new(T, Args...)(auto ref Args args) if (is(T == class)) -{ - import core.lifetime : emplace, forward; - - T mem = cast(T)__cpp_new(__traits(classInstanceSize, T)); - return mem.emplace(forward!args); -} - -void cpp_delete(T)(T* ptr) if (!is(T == class)) -{ - destroy!false(*ptr); - __cpp_delete(ptr); -} - -void cpp_delete(T)(T instance) if (is(T == class)) -{ - destroy!false(instance); - __cpp_delete(cast(void*) instance); -} - -/// Binding for ::operator new(std::size_t count) -pragma(mangle, __new_mangle) -extern(C++) void* __cpp_new(size_t count); - -/// Binding for ::operator delete(void* ptr) -pragma(mangle, __delete_mangle) -extern(C++) void __cpp_delete(void* ptr); - -// we have to hard-code the mangling for the global new/delete operators -version (CppRuntime_Microsoft) -{ - version (D_LP64) - { - enum __new_mangle = "??2@YAPEAX_K@Z"; - enum __delete_mangle = "??3@YAXPEAX@Z"; - } - else - { - enum __new_mangle = "??2@YAPAXI@Z"; - enum __delete_mangle = "??3@YAXPAX@Z"; - } -} -else -{ - version (D_LP64) - { - enum __new_mangle = "_Znwm"; - enum __delete_mangle = "_ZdlPv"; - } - else - { - enum __new_mangle = "_Znwj"; - enum __delete_mangle = "_ZdlPv"; - } -} diff --git a/compiler/test/dshell/extra-files/dll_cxx/testdll.d b/compiler/test/dshell/extra-files/dll_cxx/testdll.d index 287176dce0..1c852aa104 100644 --- a/compiler/test/dshell/extra-files/dll_cxx/testdll.d +++ b/compiler/test/dshell/extra-files/dll_cxx/testdll.d @@ -24,7 +24,7 @@ extern(C++) struct S22323 void test22323() { - import cppnew; + import core.stdcpp.new_; assert(C22323.ctorCount == 0); assert(C22323.dtorCount == 0);