diff --git a/src/bindgen/ir/structure.rs b/src/bindgen/ir/structure.rs index 3db3e7a48..7851350fe 100644 --- a/src/bindgen/ir/structure.rs +++ b/src/bindgen/ir/structure.rs @@ -223,7 +223,8 @@ impl Struct { out.open_brace(); write!( out, - "return {{static_cast(this->bits {} {}.bits)}};", + "return {} {{ static_cast(this->bits {} {}.bits) }};", + self.export_name(), operator, other ); out.close_brace(false); @@ -553,7 +554,7 @@ impl Source for Struct { self.export_name() ); out.open_brace(); - write!(out, "return {{static_cast(~bits)}};"); + write!(out, "return {} {{ static_cast(~bits) }};", self.export_name()); out.close_brace(false); self.emit_bitflags_binop(constexpr_prefix, '|', &other, out); self.emit_bitflags_binop(constexpr_prefix, '&', &other, out); diff --git a/tests/expectations/associated_in_body.cpp b/tests/expectations/associated_in_body.cpp index d1319efb4..e93a63fb0 100644 --- a/tests/expectations/associated_in_body.cpp +++ b/tests/expectations/associated_in_body.cpp @@ -14,24 +14,24 @@ struct StyleAlignFlags { return !!bits; } constexpr StyleAlignFlags operator~() const { - return {static_cast(~bits)}; + return StyleAlignFlags { static_cast(~bits) }; } constexpr StyleAlignFlags operator|(const StyleAlignFlags& other) const { - return {static_cast(this->bits | other.bits)}; + return StyleAlignFlags { static_cast(this->bits | other.bits) }; } StyleAlignFlags& operator|=(const StyleAlignFlags& other) { *this = (*this | other); return *this; } constexpr StyleAlignFlags operator&(const StyleAlignFlags& other) const { - return {static_cast(this->bits & other.bits)}; + return StyleAlignFlags { static_cast(this->bits & other.bits) }; } StyleAlignFlags& operator&=(const StyleAlignFlags& other) { *this = (*this & other); return *this; } constexpr StyleAlignFlags operator^(const StyleAlignFlags& other) const { - return {static_cast(this->bits ^ other.bits)}; + return StyleAlignFlags { static_cast(this->bits ^ other.bits) }; } StyleAlignFlags& operator^=(const StyleAlignFlags& other) { *this = (*this ^ other); diff --git a/tests/expectations/bitflags.cpp b/tests/expectations/bitflags.cpp index 9df48b696..6ed473665 100644 --- a/tests/expectations/bitflags.cpp +++ b/tests/expectations/bitflags.cpp @@ -14,24 +14,24 @@ struct AlignFlags { return !!bits; } constexpr AlignFlags operator~() const { - return {static_cast(~bits)}; + return AlignFlags { static_cast(~bits) }; } constexpr AlignFlags operator|(const AlignFlags& other) const { - return {static_cast(this->bits | other.bits)}; + return AlignFlags { static_cast(this->bits | other.bits) }; } AlignFlags& operator|=(const AlignFlags& other) { *this = (*this | other); return *this; } constexpr AlignFlags operator&(const AlignFlags& other) const { - return {static_cast(this->bits & other.bits)}; + return AlignFlags { static_cast(this->bits & other.bits) }; } AlignFlags& operator&=(const AlignFlags& other) { *this = (*this & other); return *this; } constexpr AlignFlags operator^(const AlignFlags& other) const { - return {static_cast(this->bits ^ other.bits)}; + return AlignFlags { static_cast(this->bits ^ other.bits) }; } AlignFlags& operator^=(const AlignFlags& other) { *this = (*this ^ other); @@ -59,24 +59,24 @@ struct DebugFlags { return !!bits; } constexpr DebugFlags operator~() const { - return {static_cast(~bits)}; + return DebugFlags { static_cast(~bits) }; } constexpr DebugFlags operator|(const DebugFlags& other) const { - return {static_cast(this->bits | other.bits)}; + return DebugFlags { static_cast(this->bits | other.bits) }; } DebugFlags& operator|=(const DebugFlags& other) { *this = (*this | other); return *this; } constexpr DebugFlags operator&(const DebugFlags& other) const { - return {static_cast(this->bits & other.bits)}; + return DebugFlags { static_cast(this->bits & other.bits) }; } DebugFlags& operator&=(const DebugFlags& other) { *this = (*this & other); return *this; } constexpr DebugFlags operator^(const DebugFlags& other) const { - return {static_cast(this->bits ^ other.bits)}; + return DebugFlags { static_cast(this->bits ^ other.bits) }; } DebugFlags& operator^=(const DebugFlags& other) { *this = (*this ^ other); @@ -93,24 +93,24 @@ struct LargeFlags { return !!bits; } constexpr LargeFlags operator~() const { - return {static_cast(~bits)}; + return LargeFlags { static_cast(~bits) }; } constexpr LargeFlags operator|(const LargeFlags& other) const { - return {static_cast(this->bits | other.bits)}; + return LargeFlags { static_cast(this->bits | other.bits) }; } LargeFlags& operator|=(const LargeFlags& other) { *this = (*this | other); return *this; } constexpr LargeFlags operator&(const LargeFlags& other) const { - return {static_cast(this->bits & other.bits)}; + return LargeFlags { static_cast(this->bits & other.bits) }; } LargeFlags& operator&=(const LargeFlags& other) { *this = (*this & other); return *this; } constexpr LargeFlags operator^(const LargeFlags& other) const { - return {static_cast(this->bits ^ other.bits)}; + return LargeFlags { static_cast(this->bits ^ other.bits) }; } LargeFlags& operator^=(const LargeFlags& other) { *this = (*this ^ other);