From 61bf4d15ab5cc13bd95e3b79e59499eb78e36765 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Fri, 14 Jul 2023 09:49:50 -0700 Subject: [PATCH] Fixup Yoga UT compilation on non-clang compilers (#1333) Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1333 Yoga is compiled on more than clang, both internally, and in OSS. D47345669 added unguarded usage of ` #pragma clang diagnostic push` to Yoga UTs which will cause unrecognized pragma errors if building the tests on other platforms. The code here is flagged for implicitly converting enum to float. This is test code which is using the enum as an arbitrary differentiating input, so I just changed this to an explicit cast, which I assume should silence the warning. Reviewed By: NuriAmari Differential Revision: D47460301 fbshipit-source-id: 952ff61e0c26deb8bbff8b860faf30896753a3bd --- tests/YGNodeCallbackTest.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tests/YGNodeCallbackTest.cpp b/tests/YGNodeCallbackTest.cpp index a130e66b..754c03c6 100644 --- a/tests/YGNodeCallbackTest.cpp +++ b/tests/YGNodeCallbackTest.cpp @@ -33,11 +33,7 @@ TEST(YGNode, measure_with_measure_fn) { n.setMeasureFunc( [](YGNode*, float w, YGMeasureMode wm, float h, YGMeasureMode hm) { -// TODO: Correctly fix enum - float conversion warning: T158155910 -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wenum-float-conversion" - return YGSize{w * wm, h / hm}; -#pragma clang diagnostic pop + return YGSize{w * static_cast(wm), h / static_cast(hm)}; }); ASSERT_EQ( @@ -62,19 +58,11 @@ TEST(YGNode, switching_measure_fn_types) { auto n = YGNode{}; n.setMeasureFunc( [](YGNode*, float, YGMeasureMode, float, YGMeasureMode, void*) { -// TODO: Properly fix enum - float conversion warning: T158155910 -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wenum-float-conversion" return YGSize{}; -#pragma clang diagnostic pop }); n.setMeasureFunc( [](YGNode*, float w, YGMeasureMode wm, float h, YGMeasureMode hm) { -// TODO: Properly fix enum - float conversion warning: T158155910 -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wenum-float-conversion" - return YGSize{w * wm, h / hm}; -#pragma clang diagnostic pop + return YGSize{w * static_cast(wm), h / static_cast(hm)}; }); ASSERT_EQ(