test: Test ManuallyDrop as a simplified type.

This commit is contained in:
Ivan Enderlin
2020-09-24 14:20:22 +02:00
committed by Emilio Cobos Álvarez
parent f7471e5a5e
commit 79bb38abda
8 changed files with 201 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
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);
@@ -0,0 +1,29 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
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
+21
View File
@@ -0,0 +1,21 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
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);
+29
View File
@@ -0,0 +1,29 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
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
+29
View File
@@ -0,0 +1,29 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <new>
template<typename T = void>
struct ManuallyDrop;
template<typename T = void>
struct NotReprC;
struct Point {
int32_t x;
int32_t y;
};
using Foo = NotReprC<ManuallyDrop<Point>>;
struct MyStruct {
Point point;
};
extern "C" {
void root(const Foo *a, const MyStruct *with_manual_drop);
void take(Point with_manual_drop);
} // extern "C"
+21
View File
@@ -0,0 +1,21 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
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);
@@ -0,0 +1,29 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
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
+22
View File
@@ -0,0 +1,22 @@
#[repr(C)]
pub struct Point {
x: i32,
y: i32,
}
#[repr(C)]
pub struct MyStruct {
point: std::mem::ManuallyDrop<Point>,
}
pub struct NotReprC<T> {
inner: T,
}
pub type Foo = NotReprC<std::mem::ManuallyDrop<Point>>;
#[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<Point>) {}