diff --git a/src/bindgen/ir/enumeration.rs b/src/bindgen/ir/enumeration.rs index 7ff57c22e..49a272b46 100644 --- a/src/bindgen/ir/enumeration.rs +++ b/src/bindgen/ir/enumeration.rs @@ -422,6 +422,8 @@ impl Item for Enum { } for variant in &mut self.variants { + reserved::escape(&mut variant.export_name); + if let Some((ref mut field_name, ref mut body)) = variant.body { body.rename_for_config(config); reserved::escape(field_name); diff --git a/tests/expectations/both/reserved.c b/tests/expectations/both/reserved.c index 129ea2b41..3909b0edd 100644 --- a/tests/expectations/both/reserved.c +++ b/tests/expectations/both/reserved.c @@ -52,4 +52,26 @@ typedef struct E { }; } E; -void root(A a, B b, C c, E e, int32_t namespace_, float float_); +enum F_Tag { + double_, + float_, +}; +typedef uint8_t F_Tag; + +typedef struct double_Body { + double _0; +} double_Body; + +typedef struct float_Body { + float _0; +} float_Body; + +typedef struct F { + F_Tag tag; + union { + double_Body double_; + float_Body float_; + }; +} F; + +void root(A a, B b, C c, E e, F f, int32_t namespace_, float float_); diff --git a/tests/expectations/both/reserved.compat.c b/tests/expectations/both/reserved.compat.c index 5c52f1e11..59f5c0460 100644 --- a/tests/expectations/both/reserved.compat.c +++ b/tests/expectations/both/reserved.compat.c @@ -64,11 +64,39 @@ typedef struct E { }; } E; +enum F_Tag +#ifdef __cplusplus + : uint8_t +#endif // __cplusplus + { + double_, + float_, +}; +#ifndef __cplusplus +typedef uint8_t F_Tag; +#endif // __cplusplus + +typedef struct double_Body { + double _0; +} double_Body; + +typedef struct float_Body { + float _0; +} float_Body; + +typedef struct F { + F_Tag tag; + union { + double_Body double_; + float_Body float_; + }; +} F; + #ifdef __cplusplus extern "C" { #endif // __cplusplus -void root(A a, B b, C c, E e, int32_t namespace_, float float_); +void root(A a, B b, C c, E e, F f, int32_t namespace_, float float_); #ifdef __cplusplus } // extern "C" diff --git a/tests/expectations/reserved.c b/tests/expectations/reserved.c index 6aba4c37b..aa78bef40 100644 --- a/tests/expectations/reserved.c +++ b/tests/expectations/reserved.c @@ -52,4 +52,26 @@ typedef struct { }; } E; -void root(A a, B b, C c, E e, int32_t namespace_, float float_); +enum F_Tag { + double_, + float_, +}; +typedef uint8_t F_Tag; + +typedef struct { + double _0; +} double_Body; + +typedef struct { + float _0; +} float_Body; + +typedef struct { + F_Tag tag; + union { + double_Body double_; + float_Body float_; + }; +} F; + +void root(A a, B b, C c, E e, F f, int32_t namespace_, float float_); diff --git a/tests/expectations/reserved.compat.c b/tests/expectations/reserved.compat.c index ae551d5e2..c15ff9878 100644 --- a/tests/expectations/reserved.compat.c +++ b/tests/expectations/reserved.compat.c @@ -64,11 +64,39 @@ typedef struct { }; } E; +enum F_Tag +#ifdef __cplusplus + : uint8_t +#endif // __cplusplus + { + double_, + float_, +}; +#ifndef __cplusplus +typedef uint8_t F_Tag; +#endif // __cplusplus + +typedef struct { + double _0; +} double_Body; + +typedef struct { + float _0; +} float_Body; + +typedef struct { + F_Tag tag; + union { + double_Body double_; + float_Body float_; + }; +} F; + #ifdef __cplusplus extern "C" { #endif // __cplusplus -void root(A a, B b, C c, E e, int32_t namespace_, float float_); +void root(A a, B b, C c, E e, F f, int32_t namespace_, float float_); #ifdef __cplusplus } // extern "C" diff --git a/tests/expectations/reserved.cpp b/tests/expectations/reserved.cpp index 3394147b6..24c337afd 100644 --- a/tests/expectations/reserved.cpp +++ b/tests/expectations/reserved.cpp @@ -50,8 +50,29 @@ struct E { }; }; +struct F { + enum class Tag : uint8_t { + double_, + float_, + }; + + struct double_Body { + double _0; + }; + + struct float_Body { + float _0; + }; + + Tag tag; + union { + double_Body double_; + float_Body float_; + }; +}; + extern "C" { -void root(A a, B b, C c, E e, int32_t namespace_, float float_); +void root(A a, B b, C c, E e, F f, int32_t namespace_, float float_); } // extern "C" diff --git a/tests/expectations/tag/reserved.c b/tests/expectations/tag/reserved.c index 53ff8e7b7..abda9992d 100644 --- a/tests/expectations/tag/reserved.c +++ b/tests/expectations/tag/reserved.c @@ -52,4 +52,32 @@ struct E { }; }; -void root(struct A a, struct B b, struct C c, struct E e, int32_t namespace_, float float_); +enum F_Tag { + double_, + float_, +}; +typedef uint8_t F_Tag; + +struct double_Body { + double _0; +}; + +struct float_Body { + float _0; +}; + +struct F { + F_Tag tag; + union { + struct double_Body double_; + struct float_Body float_; + }; +}; + +void root(struct A a, + struct B b, + struct C c, + struct E e, + struct F f, + int32_t namespace_, + float float_); diff --git a/tests/expectations/tag/reserved.compat.c b/tests/expectations/tag/reserved.compat.c index ab17d8baa..bd1267f85 100644 --- a/tests/expectations/tag/reserved.compat.c +++ b/tests/expectations/tag/reserved.compat.c @@ -64,11 +64,45 @@ struct E { }; }; +enum F_Tag +#ifdef __cplusplus + : uint8_t +#endif // __cplusplus + { + double_, + float_, +}; +#ifndef __cplusplus +typedef uint8_t F_Tag; +#endif // __cplusplus + +struct double_Body { + double _0; +}; + +struct float_Body { + float _0; +}; + +struct F { + F_Tag tag; + union { + struct double_Body double_; + struct float_Body float_; + }; +}; + #ifdef __cplusplus extern "C" { #endif // __cplusplus -void root(struct A a, struct B b, struct C c, struct E e, int32_t namespace_, float float_); +void root(struct A a, + struct B b, + struct C c, + struct E e, + struct F f, + int32_t namespace_, + float float_); #ifdef __cplusplus } // extern "C" diff --git a/tests/rust/reserved.rs b/tests/rust/reserved.rs index 3d55ac064..df9d9a5ac 100644 --- a/tests/rust/reserved.rs +++ b/tests/rust/reserved.rs @@ -19,12 +19,19 @@ enum E { Float(f32), } +#[repr(C, u8)] +enum F { + double(f64), + float(f32), +} + #[no_mangle] pub extern "C" fn root( a: A, b: B, c: C, e: E, + f: F, namespace: i32, float: f32, ) { }