From 2fb857d73d6226bfbfd456ca9979488dae40aecc Mon Sep 17 00:00:00 2001 From: Uladzislau Paulovich Date: Thu, 18 Jul 2019 06:17:08 -0700 Subject: [PATCH] yoga | Fix error about implicit conversion to bit-field Summary: `YGStyle` puts Yoga enums (which are signed integers by default) into bitfields: https://fburl.com/7fowlunu Mixing signed values and bit-fields can be error-prone and it also fails to build on Windows with `clang-cl` due to `-Wbitfield-constant-conversion` warning being treated as error: ``` stderr: In file included from xplat\yoga\yoga\YGLayout.cpp:8: In file included from xplat\yoga\yoga/Utils.h:8: In file included from xplat\yoga\yoga/YGNode.h:13: xplat\yoga\yoga/YGStyle.h(110,9): error: implicit truncation from 'YGAlign' to bit-field changes value from 4 to -4 [-Werror,-Wbitfield-constant-conversion] alignItems_(YGAlignStretch), ``` This diff fixes the problem by making all enums unsigned integers. This change can be problematic only if values of the enums are serialized somewhere. CC: David Aurelio Reviewed By: davidaurelio Differential Revision: D16336729 fbshipit-source-id: ee4dabd7bd1ee429e644bd322b375ec2694cc742 --- yoga/YGStyle.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/yoga/YGStyle.h b/yoga/YGStyle.h index edefcb7c..ce381604 100644 --- a/yoga/YGStyle.h +++ b/yoga/YGStyle.h @@ -102,6 +102,11 @@ public: } }; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wbitfield-constant-conversion" +#endif + YGStyle() : direction_(YGDirectionInherit), flexDirection_(YGFlexDirectionColumn), @@ -113,6 +118,11 @@ public: flexWrap_(YGWrapNoWrap), overflow_(YGOverflowVisible), display_(YGDisplayFlex) {} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + ~YGStyle() = default; static constexpr int directionBit = 0;