From 0fed9eebc47abcd31e0e69357cd39262c8a5a6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 10 Apr 2020 13:02:18 +0200 Subject: [PATCH] enum: Unconditionally generate a return statement in partialeq implementations. This fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1628754#c7 --- src/bindgen/ir/enumeration.rs | 6 +++++- tests/expectations/cfg.cpp | 3 ++- tests/expectations/derive-eq.cpp | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bindgen/ir/enumeration.rs b/src/bindgen/ir/enumeration.rs index 49a272b..5fdcde2 100644 --- a/src/bindgen/ir/enumeration.rs +++ b/src/bindgen/ir/enumeration.rs @@ -946,9 +946,13 @@ impl Source for Enum { } } if !exhaustive { - write!(out, "default: return true;"); + write!(out, "default: break;"); } out.close_brace(false); + + out.new_line(); + write!(out, "return true;"); + out.close_brace(false); if config.structure.derive_neq(&self.annotations) { diff --git a/tests/expectations/cfg.cpp b/tests/expectations/cfg.cpp index 88f82c6..2bf46aa 100644 --- a/tests/expectations/cfg.cpp +++ b/tests/expectations/cfg.cpp @@ -124,8 +124,9 @@ union C { #if defined(PLATFORM_UNIX) case Tag::C5: return c5 == other.c5; #endif - default: return true; + default: break; } + return true; } bool operator!=(const C& other) const { diff --git a/tests/expectations/derive-eq.cpp b/tests/expectations/derive-eq.cpp index ea1ae53..6a6f5be 100644 --- a/tests/expectations/derive-eq.cpp +++ b/tests/expectations/derive-eq.cpp @@ -82,8 +82,9 @@ union Bar { case Tag::Bazz: return bazz == aOther.bazz; case Tag::FooNamed: return foo_named == aOther.foo_named; case Tag::FooParen: return foo_paren == aOther.foo_paren; - default: return true; + default: break; } + return true; } bool operator!=(const Bar& aOther) const {