Add tests for #475.

This commit is contained in:
Emilio Cobos Álvarez
2020-02-22 14:15:42 +01:00
parent 776d010aab
commit 69b3d20a92
8 changed files with 453 additions and 11 deletions
@@ -165,4 +165,47 @@ typedef union Tazz {
Taz2_Body taz2;
} Tazz;
void root(const Foo_u32 *a, const Baz_i32 *b, const Taz *c, Tazz d);
enum Tazzz_Tag {
Bar5,
Taz5,
};
typedef uint8_t Tazzz_Tag;
typedef struct Taz5_Body {
Tazzz_Tag tag;
int32_t _0;
} Taz5_Body;
typedef union Tazzz {
Tazzz_Tag tag;
Taz5_Body taz5;
} Tazzz;
enum Tazzzz_Tag {
Taz6,
Taz7,
};
typedef uint8_t Tazzzz_Tag;
typedef struct Taz6_Body {
Tazzzz_Tag tag;
int32_t _0;
} Taz6_Body;
typedef struct Taz7_Body {
Tazzzz_Tag tag;
uint32_t _0;
} Taz7_Body;
typedef union Tazzzz {
Tazzzz_Tag tag;
Taz6_Body taz6;
Taz7_Body taz7;
} Tazzzz;
void root(const Foo_u32 *a,
const Baz_i32 *b,
const Taz *c,
Tazz d,
const Tazzz *e,
const Tazzzz *f);
@@ -195,11 +195,66 @@ typedef union Tazz {
Taz2_Body taz2;
} Tazz;
enum Tazzz_Tag
#ifdef __cplusplus
: uint8_t
#endif // __cplusplus
{
Bar5,
Taz5,
};
#ifndef __cplusplus
typedef uint8_t Tazzz_Tag;
#endif // __cplusplus
typedef struct Taz5_Body {
Tazzz_Tag tag;
int32_t _0;
} Taz5_Body;
typedef union Tazzz {
Tazzz_Tag tag;
Taz5_Body taz5;
} Tazzz;
enum Tazzzz_Tag
#ifdef __cplusplus
: uint8_t
#endif // __cplusplus
{
Taz6,
Taz7,
};
#ifndef __cplusplus
typedef uint8_t Tazzzz_Tag;
#endif // __cplusplus
typedef struct Taz6_Body {
Tazzzz_Tag tag;
int32_t _0;
} Taz6_Body;
typedef struct Taz7_Body {
Tazzzz_Tag tag;
uint32_t _0;
} Taz7_Body;
typedef union Tazzzz {
Tazzzz_Tag tag;
Taz6_Body taz6;
Taz7_Body taz7;
} Tazzzz;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void root(const Foo_u32 *a, const Baz_i32 *b, const Taz *c, Tazz d);
void root(const Foo_u32 *a,
const Baz_i32 *b,
const Taz *c,
Tazz d,
const Tazzz *e,
const Tazzzz *f);
#ifdef __cplusplus
} // extern "C"
+44 -1
View File
@@ -165,4 +165,47 @@ typedef union {
Taz2_Body taz2;
} Tazz;
void root(const Foo_u32 *a, const Baz_i32 *b, const Taz *c, Tazz d);
enum Tazzz_Tag {
Bar5,
Taz5,
};
typedef uint8_t Tazzz_Tag;
typedef struct {
Tazzz_Tag tag;
int32_t _0;
} Taz5_Body;
typedef union {
Tazzz_Tag tag;
Taz5_Body taz5;
} Tazzz;
enum Tazzzz_Tag {
Taz6,
Taz7,
};
typedef uint8_t Tazzzz_Tag;
typedef struct {
Tazzzz_Tag tag;
int32_t _0;
} Taz6_Body;
typedef struct {
Tazzzz_Tag tag;
uint32_t _0;
} Taz7_Body;
typedef union {
Tazzzz_Tag tag;
Taz6_Body taz6;
Taz7_Body taz7;
} Tazzzz;
void root(const Foo_u32 *a,
const Baz_i32 *b,
const Taz *c,
Tazz d,
const Tazzz *e,
const Tazzzz *f);
@@ -195,11 +195,66 @@ typedef union {
Taz2_Body taz2;
} Tazz;
enum Tazzz_Tag
#ifdef __cplusplus
: uint8_t
#endif // __cplusplus
{
Bar5,
Taz5,
};
#ifndef __cplusplus
typedef uint8_t Tazzz_Tag;
#endif // __cplusplus
typedef struct {
Tazzz_Tag tag;
int32_t _0;
} Taz5_Body;
typedef union {
Tazzz_Tag tag;
Taz5_Body taz5;
} Tazzz;
enum Tazzzz_Tag
#ifdef __cplusplus
: uint8_t
#endif // __cplusplus
{
Taz6,
Taz7,
};
#ifndef __cplusplus
typedef uint8_t Tazzzz_Tag;
#endif // __cplusplus
typedef struct {
Tazzzz_Tag tag;
int32_t _0;
} Taz6_Body;
typedef struct {
Tazzzz_Tag tag;
uint32_t _0;
} Taz7_Body;
typedef union {
Tazzzz_Tag tag;
Taz6_Body taz6;
Taz7_Body taz7;
} Tazzzz;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void root(const Foo_u32 *a, const Baz_i32 *b, const Taz *c, Tazz d);
void root(const Foo_u32 *a,
const Baz_i32 *b,
const Taz *c,
Tazz d,
const Tazzz *e,
const Tazzzz *f);
#ifdef __cplusplus
} // extern "C"
+142 -1
View File
@@ -458,8 +458,149 @@ union Tazz {
};
union Tazzz {
enum class Tag : uint8_t {
Bar5,
Taz5,
};
struct Taz5_Body {
Tag tag;
int32_t _0;
};
struct {
Tag tag;
};
Taz5_Body taz5;
static Tazzz Bar5() {
Tazzz result;
result.tag = Tag::Bar5;
return result;
}
bool IsBar5() const {
return tag == Tag::Bar5;
}
static Tazzz Taz5(const int32_t &a0) {
Tazzz result;
::new (&result.taz5._0) (int32_t)(a0);
result.tag = Tag::Taz5;
return result;
}
bool IsTaz5() const {
return tag == Tag::Taz5;
}
private:
Tazzz() {
}
public:
~Tazzz() {
switch (tag) {
case Tag::Taz5: taz5.~Taz5_Body(); break;
default: break;
}
}
Tazzz(const Tazzz& other)
: tag(other.tag) {
switch (tag) {
case Tag::Taz5: ::new (&taz5) (Taz5_Body)(other.taz5); break;
default: break;
}
}
};
union Tazzzz {
enum class Tag : uint8_t {
Taz6,
Taz7,
};
struct Taz6_Body {
Tag tag;
int32_t _0;
};
struct Taz7_Body {
Tag tag;
uint32_t _0;
};
struct {
Tag tag;
};
Taz6_Body taz6;
Taz7_Body taz7;
static Tazzzz Taz6(const int32_t &a0) {
Tazzzz result;
::new (&result.taz6._0) (int32_t)(a0);
result.tag = Tag::Taz6;
return result;
}
bool IsTaz6() const {
return tag == Tag::Taz6;
}
static Tazzzz Taz7(const uint32_t &a0) {
Tazzzz result;
::new (&result.taz7._0) (uint32_t)(a0);
result.tag = Tag::Taz7;
return result;
}
bool IsTaz7() const {
return tag == Tag::Taz7;
}
private:
Tazzzz() {
}
public:
~Tazzzz() {
switch (tag) {
case Tag::Taz6: taz6.~Taz6_Body(); break;
case Tag::Taz7: taz7.~Taz7_Body(); break;
}
}
Tazzzz(const Tazzzz& other)
: tag(other.tag) {
switch (tag) {
case Tag::Taz6: ::new (&taz6) (Taz6_Body)(other.taz6); break;
case Tag::Taz7: ::new (&taz7) (Taz7_Body)(other.taz7); break;
}
}
Tazzzz& operator=(const Tazzzz& other) {
if (this != &other) {
this->~Tazzzz();
new (this) Tazzzz(other);
}
return *this;
}
};
extern "C" {
void root(const Foo<uint32_t> *a, const Baz<int32_t> *b, const Taz *c, Tazz d);
void root(const Foo<uint32_t> *a,
const Baz<int32_t> *b,
const Taz *c,
Tazz d,
const Tazzz *e,
const Tazzzz *f);
} // extern "C"
@@ -165,4 +165,47 @@ union Tazz {
struct Taz2_Body taz2;
};
void root(const struct Foo_u32 *a, const union Baz_i32 *b, const union Taz *c, union Tazz d);
enum Tazzz_Tag {
Bar5,
Taz5,
};
typedef uint8_t Tazzz_Tag;
struct Taz5_Body {
Tazzz_Tag tag;
int32_t _0;
};
union Tazzz {
Tazzz_Tag tag;
struct Taz5_Body taz5;
};
enum Tazzzz_Tag {
Taz6,
Taz7,
};
typedef uint8_t Tazzzz_Tag;
struct Taz6_Body {
Tazzzz_Tag tag;
int32_t _0;
};
struct Taz7_Body {
Tazzzz_Tag tag;
uint32_t _0;
};
union Tazzzz {
Tazzzz_Tag tag;
struct Taz6_Body taz6;
struct Taz7_Body taz7;
};
void root(const struct Foo_u32 *a,
const union Baz_i32 *b,
const union Taz *c,
union Tazz d,
const union Tazzz *e,
const union Tazzzz *f);
@@ -195,11 +195,66 @@ union Tazz {
struct Taz2_Body taz2;
};
enum Tazzz_Tag
#ifdef __cplusplus
: uint8_t
#endif // __cplusplus
{
Bar5,
Taz5,
};
#ifndef __cplusplus
typedef uint8_t Tazzz_Tag;
#endif // __cplusplus
struct Taz5_Body {
Tazzz_Tag tag;
int32_t _0;
};
union Tazzz {
Tazzz_Tag tag;
struct Taz5_Body taz5;
};
enum Tazzzz_Tag
#ifdef __cplusplus
: uint8_t
#endif // __cplusplus
{
Taz6,
Taz7,
};
#ifndef __cplusplus
typedef uint8_t Tazzzz_Tag;
#endif // __cplusplus
struct Taz6_Body {
Tazzzz_Tag tag;
int32_t _0;
};
struct Taz7_Body {
Tazzzz_Tag tag;
uint32_t _0;
};
union Tazzzz {
Tazzzz_Tag tag;
struct Taz6_Body taz6;
struct Taz7_Body taz7;
};
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void root(const struct Foo_u32 *a, const union Baz_i32 *b, const union Taz *c, union Tazz d);
void root(const struct Foo_u32 *a,
const union Baz_i32 *b,
const union Taz *c,
union Tazz d,
const union Tazzz *e,
const union Tazzzz *f);
#ifdef __cplusplus
} // extern "C"
+11 -4
View File
@@ -66,10 +66,17 @@ pub enum Tazz {
/// cbindgen:derive-tagged-enum-copy-assignment=false
#[repr(u8)]
pub enum Tazz {
Bar4,
Taz2(i32),
pub enum Tazzz {
Bar5,
Taz5(i32),
}
#[repr(u8)]
pub enum Tazzzz {
Taz6(i32),
Taz7(u32),
}
#[no_mangle]
pub extern "C" fn root(a: &Foo<u32>, b: &Baz<i32>, c: &Taz, d: Tazz) {}
pub extern "C" fn root(a: &Foo<u32>, b: &Baz<i32>, c: &Taz, d: Tazz, e: &Tazzz, f: &Tazzzz) {}