Files
swift-mirror/test/Interop/Cxx/class/Inputs/destructors.h
Egor Zhdan 34c796d100 [cxx-interop] Add a test for instantiation of a default destructor
This is a follow-up to f56fa41.

rdar://124061505
2024-07-04 17:35:01 +01:00

44 lines
1.3 KiB
C++

#ifndef TEST_INTEROP_CXX_CLASS_INPUTS_DESTRUCTORS_H
#define TEST_INTEROP_CXX_CLASS_INPUTS_DESTRUCTORS_H
struct DummyStruct {};
struct __attribute__((swift_attr("import_unsafe")))
HasUserProvidedDestructorAndDummy {
DummyStruct dummy;
HasUserProvidedDestructorAndDummy(DummyStruct dummy) : dummy(dummy) {}
#if __is_target_os(windows)
// On windows, force this type to be address-only.
HasUserProvidedDestructorAndDummy(const HasUserProvidedDestructorAndDummy &) {}
#endif
~HasUserProvidedDestructorAndDummy() {}
};
struct __attribute__((swift_attr("import_unsafe"))) HasUserProvidedDestructor {
int *value;
#if __is_target_os(windows)
// On windows, force this type to be address-only.
HasUserProvidedDestructor() {}
HasUserProvidedDestructor(const HasUserProvidedDestructor &other) {}
#endif
~HasUserProvidedDestructor() { *value = 42; }
};
struct HasNonTrivialImplicitDestructor {
HasUserProvidedDestructor member;
};
template <typename T>
struct TemplatedHasVirtualDestructor {
T value;
virtual ~TemplatedHasVirtualDestructor() {}
};
template <typename T>
struct DerivedTemplatedHasVirtualDestructor : TemplatedHasVirtualDestructor<T> {
};
using DerivedTemplatedHasVirtualDestructorChar = DerivedTemplatedHasVirtualDestructor<char>;
#endif // TEST_INTEROP_CXX_CLASS_INPUTS_DESTRUCTORS_H