[gjs: 10/18] test: Silence self-assignment clang warning in a more idiomatic way




commit d1f2807f00a34865816037ff73b8b2ea2d301f11
Author: Philip Chimento <philip chimento gmail com>
Date:   Thu Nov 26 19:54:36 2020 -0800

    test: Silence self-assignment clang warning in a more idiomatic way
    
    Clang also understands the idiom `a = *&a` to silence warnings about self-
    assignment if it is done intentionally.

 test/gjs-test-jsapi-utils.cpp | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
---
diff --git a/test/gjs-test-jsapi-utils.cpp b/test/gjs-test-jsapi-utils.cpp
index 046fbb90..a6f01426 100644
--- a/test/gjs-test-jsapi-utils.cpp
+++ b/test/gjs-test-jsapi-utils.cpp
@@ -251,14 +251,7 @@ static void test_gjs_autopointer_assign_operator_self_object(Fixture* fx,
                                                              const void*) {
     GjsAutoTestObject autoptr(fx->ptr);
 
-#if defined(__clang__)
-#    pragma clang diagnostic push
-#    pragma clang diagnostic ignored "-Wself-assign"
-#endif
-    autoptr = autoptr;
-#if defined(__clang__)
-#    pragma clang diagnostic pop
-#endif
+    autoptr = *&autoptr;
 
     g_assert_true(autoptr == fx->ptr);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]