mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00

For the new Linux/Fedora configuration with introduction of gcc 7.2, compilation of this file issues a new warning due to the correct diagnosis of an ambiguous 'else'. As warnings are being treated as errors, this aborts the build. The diagnostic: vpg-compute-neo/unit_tests/elflib/elflib_tests.cpp:123:12: error: suggest explicit braces to avoid ambiguous 'else' [-Werror=dangling-else] if (nonfailingAllocation == failureIndex) ^ Diagnosis: The diagnostic suggested that this: if (nonfailingAllocation == failureIndex) ASSERT_NE(nullptr, pWriter); should be changed to: if (nonfailingAllocation == failureIndex) { ASSERT_NE(nullptr, pWriter); } This is a valid suggestion. The same is true for EXPECT_EQ. Pick the files in repository ssh://gerrit-gfx.intel.com:29418/mirrors/github/google/googletest for tracing the definition. (There are many versions of gtest.h under the ufo tree). Starting in file include/gtest/gtest.h, the definition of ASSERT_NE can be traced back towards its origin as follows: ASSERT_NE include/gtest/gtest.h GTEST_ASSERT_NE include/gtest/gtest.h ASSERT_PRED_FORMAT2 include/gtest/gtest_pred_impl.h GTEST_PRED_FORMAT2_ include/gtest/gtest_pred_impl.h GTEST_ASSERT_ include/gtest/gtest_pred_impl.h where GTEST_ASSERT_ indeed *should* be enclosed in braces. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ if (const ::testing::AssertionResult gtest_ar = (expression)) \ ; \ else \ on_failure(gtest_ar.failure_message()) The correct fix would be to place the braces in the macro definition. However, as file gtest.h comes from Google, and as there are 37 different versions of it in the source tree, this workaround will address the macro invocations. Should it be desirable, it is left to others to correct gtest.h and friends. Change-Id: I870d38ba623fc7564f894c7b1ea7512b74244ee2 Signed-off-by: Dale Stimson <dale.b.stimson@intel.com>