This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new a65745e  faststring-test: squelch unknown pragmas warning when 
building with gcc
a65745e is described below

commit a65745e5e9c189f13ac966deb542a1ac22870654
Author: Adar Dembo <[email protected]>
AuthorDate: Wed Feb 19 10:41:55 2020 -0800

    faststring-test: squelch unknown pragmas warning when building with gcc
    
    When building faststring-test with gcc, we see these warnings:
    
      ../../src/kudu/util/faststring-test.cc:171:0: warning: ignoring #pragma 
clang diagnostic [-Wunknown-pragmas]
       #pragma clang diagnostic push
    
      ../../src/kudu/util/faststring-test.cc:172:0: warning: ignoring #pragma 
clang diagnostic [-Wunknown-pragmas]
       #pragma clang diagnostic ignored "-Wself-move"
    
      ../../src/kudu/util/faststring-test.cc:174:0: warning: ignoring #pragma 
clang diagnostic [-Wunknown-pragmas]
       #pragma clang diagnostic pop
    
    It doesn't appear to be possible to squelch these via additional pragmas, so
    we instead do it in CMake.
    
    Change-Id: Ifa3c1ad13999b64ecfffcab4eb058c2da0c664a7
    Reviewed-on: http://gerrit.cloudera.org:8080/15245
    Reviewed-by: Alexey Serbin <[email protected]>
    Tested-by: Kudu Jenkins
---
 src/kudu/util/CMakeLists.txt     | 20 ++++++++++++++++++++
 src/kudu/util/faststring-test.cc |  5 +----
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/kudu/util/CMakeLists.txt b/src/kudu/util/CMakeLists.txt
index e4a5689..b09b495 100644
--- a/src/kudu/util/CMakeLists.txt
+++ b/src/kudu/util/CMakeLists.txt
@@ -447,7 +447,27 @@ ADD_KUDU_TEST(easy_json-test)
 ADD_KUDU_TEST(env-test LABELS no_tsan)
 ADD_KUDU_TEST(env_util-test)
 ADD_KUDU_TEST(errno-test)
+
+# There's a move in faststring-test.cc that looks like this:
+#
+#   f1 = std::move(f1);
+#
+# Self-moves are generally undesirable, and Clang warns about them via the
+# -Wself-move flag. In this particular case, we're explicitly testing self-move
+# behavior, so we don't want any warnings.
+#
+# Unfortunately, if we disable -Wself-move via clang diagnostic pragmas, we'll
+# wind up triggering gcc's -Wunknown-pragmas warning. And due to a 
long-standing
+# bug[1], we can't disable -Wunknown-pragmas via GCC diagnostic pragmas. So we
+# must disable the warning for the entirety of the compilation unit.
+#
+# 1. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
+if("${COMPILER_FAMILY}" STREQUAL "clang")
+  set_source_files_properties(faststring-test.cc PROPERTIES COMPILE_FLAGS
+    "-Wno-self-move")
+endif()
 ADD_KUDU_TEST(faststring-test)
+
 ADD_KUDU_TEST(file_cache-test)
 ADD_KUDU_TEST(file_cache-stress-test RUN_SERIAL true)
 ADD_KUDU_TEST(flag_tags-test)
diff --git a/src/kudu/util/faststring-test.cc b/src/kudu/util/faststring-test.cc
index 9585e6e..d5c450c 100644
--- a/src/kudu/util/faststring-test.cc
+++ b/src/kudu/util/faststring-test.cc
@@ -166,12 +166,9 @@ TEST_F(FaststringTest, TestMoveAssignment) {
     f2.CheckInvariants(); // NOLINT(*)
 
     // Check self-move doesn't have any effect.
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wself-move"
     f1 = std::move(f1); // NOLINT(*)
-#pragma clang diagnostic pop
     ASSERT_EQ(0, f2.size()); // NOLINT(*)
-    ASSERT_EQ(test_str, f1.ToString());
+    ASSERT_EQ(test_str, f1.ToString()); // NOLINT(*)
     f1.CheckInvariants(); // NOLINT(*)
     f2.CheckInvariants(); // NOLINT(*)
   }

Reply via email to