From 79bb38abdaf64fda8edbb3a0afea44bdefd7174e Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 24 Sep 2020 14:20:22 +0200 Subject: [PATCH] test: Test `ManuallyDrop` as a simplified type. --- tests/expectations/both/manuallydrop.c | 21 ++++++++++++++ tests/expectations/both/manuallydrop.compat.c | 29 +++++++++++++++++++ tests/expectations/manuallydrop.c | 21 ++++++++++++++ tests/expectations/manuallydrop.compat.c | 29 +++++++++++++++++++ tests/expectations/manuallydrop.cpp | 29 +++++++++++++++++++ tests/expectations/tag/manuallydrop.c | 21 ++++++++++++++ tests/expectations/tag/manuallydrop.compat.c | 29 +++++++++++++++++++ tests/rust/manuallydrop.rs | 22 ++++++++++++++ 8 files changed, 201 insertions(+) create mode 100644 tests/expectations/both/manuallydrop.c create mode 100644 tests/expectations/both/manuallydrop.compat.c create mode 100644 tests/expectations/manuallydrop.c create mode 100644 tests/expectations/manuallydrop.compat.c create mode 100644 tests/expectations/manuallydrop.cpp create mode 100644 tests/expectations/tag/manuallydrop.c create mode 100644 tests/expectations/tag/manuallydrop.compat.c create mode 100644 tests/rust/manuallydrop.rs diff --git a/tests/expectations/both/manuallydrop.c b/tests/expectations/both/manuallydrop.c new file mode 100644 index 0000000..8e942fa --- /dev/null +++ b/tests/expectations/both/manuallydrop.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +typedef struct NotReprC_ManuallyDrop_Point NotReprC_ManuallyDrop_Point; + +typedef NotReprC_ManuallyDrop_Point Foo; + +typedef struct Point { + int32_t x; + int32_t y; +} Point; + +typedef struct MyStruct { + Point point; +} MyStruct; + +void root(const Foo *a, const MyStruct *with_manual_drop); + +void take(Point with_manual_drop); diff --git a/tests/expectations/both/manuallydrop.compat.c b/tests/expectations/both/manuallydrop.compat.c new file mode 100644 index 0000000..6eb3444 --- /dev/null +++ b/tests/expectations/both/manuallydrop.compat.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +typedef struct NotReprC_ManuallyDrop_Point NotReprC_ManuallyDrop_Point; + +typedef NotReprC_ManuallyDrop_Point Foo; + +typedef struct Point { + int32_t x; + int32_t y; +} Point; + +typedef struct MyStruct { + Point point; +} MyStruct; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(const Foo *a, const MyStruct *with_manual_drop); + +void take(Point with_manual_drop); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/manuallydrop.c b/tests/expectations/manuallydrop.c new file mode 100644 index 0000000..c4c4c23 --- /dev/null +++ b/tests/expectations/manuallydrop.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +typedef struct NotReprC_ManuallyDrop_Point NotReprC_ManuallyDrop_Point; + +typedef NotReprC_ManuallyDrop_Point Foo; + +typedef struct { + int32_t x; + int32_t y; +} Point; + +typedef struct { + Point point; +} MyStruct; + +void root(const Foo *a, const MyStruct *with_manual_drop); + +void take(Point with_manual_drop); diff --git a/tests/expectations/manuallydrop.compat.c b/tests/expectations/manuallydrop.compat.c new file mode 100644 index 0000000..baac99a --- /dev/null +++ b/tests/expectations/manuallydrop.compat.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +typedef struct NotReprC_ManuallyDrop_Point NotReprC_ManuallyDrop_Point; + +typedef NotReprC_ManuallyDrop_Point Foo; + +typedef struct { + int32_t x; + int32_t y; +} Point; + +typedef struct { + Point point; +} MyStruct; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(const Foo *a, const MyStruct *with_manual_drop); + +void take(Point with_manual_drop); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/manuallydrop.cpp b/tests/expectations/manuallydrop.cpp new file mode 100644 index 0000000..2da46ec --- /dev/null +++ b/tests/expectations/manuallydrop.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +template +struct ManuallyDrop; + +template +struct NotReprC; + +struct Point { + int32_t x; + int32_t y; +}; + +using Foo = NotReprC>; + +struct MyStruct { + Point point; +}; + +extern "C" { + +void root(const Foo *a, const MyStruct *with_manual_drop); + +void take(Point with_manual_drop); + +} // extern "C" diff --git a/tests/expectations/tag/manuallydrop.c b/tests/expectations/tag/manuallydrop.c new file mode 100644 index 0000000..193bfba --- /dev/null +++ b/tests/expectations/tag/manuallydrop.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +struct NotReprC_ManuallyDrop_Point; + +typedef struct NotReprC_ManuallyDrop_Point Foo; + +struct Point { + int32_t x; + int32_t y; +}; + +struct MyStruct { + struct Point point; +}; + +void root(const Foo *a, const struct MyStruct *with_manual_drop); + +void take(struct Point with_manual_drop); diff --git a/tests/expectations/tag/manuallydrop.compat.c b/tests/expectations/tag/manuallydrop.compat.c new file mode 100644 index 0000000..55cea1b --- /dev/null +++ b/tests/expectations/tag/manuallydrop.compat.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +struct NotReprC_ManuallyDrop_Point; + +typedef struct NotReprC_ManuallyDrop_Point Foo; + +struct Point { + int32_t x; + int32_t y; +}; + +struct MyStruct { + struct Point point; +}; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void root(const Foo *a, const struct MyStruct *with_manual_drop); + +void take(struct Point with_manual_drop); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/rust/manuallydrop.rs b/tests/rust/manuallydrop.rs new file mode 100644 index 0000000..fea2537 --- /dev/null +++ b/tests/rust/manuallydrop.rs @@ -0,0 +1,22 @@ +#[repr(C)] +pub struct Point { + x: i32, + y: i32, +} + +#[repr(C)] +pub struct MyStruct { + point: std::mem::ManuallyDrop, +} + +pub struct NotReprC { + inner: T, +} + +pub type Foo = NotReprC>; + +#[no_mangle] +pub extern "C" fn root(a: &Foo, with_manual_drop: &MyStruct) {} + +#[no_mangle] +pub extern "C" fn take(with_manual_drop: std::mem::ManuallyDrop) {}