lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master af7bdb9: Suppress '-Weffc++' in special cases


From: Greg Chicares
Subject: [lmi-commits] [lmi] master af7bdb9: Suppress '-Weffc++' in special cases
Date: Tue, 9 Jun 2020 13:05:52 -0400 (EDT)

branch: master
commit af7bdb971653aea5ad67080cd600da316e53a5c2
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Suppress '-Weffc++' in special cases
    
    '-Weffc++' should be enabled at least as an occasional experiment.
    But it should always be suppressed for
     - boost TUs (which are not '-Weffc++'-clean), and
     - PETE, which has good reason to overload its && and || operators.
---
 tools/pete-2.1.1/et_vector.hpp | 16 ++++++++++++++++
 workhorse.make                 |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/tools/pete-2.1.1/et_vector.hpp b/tools/pete-2.1.1/et_vector.hpp
index e09e675..fbb6c6a 100644
--- a/tools/pete-2.1.1/et_vector.hpp
+++ b/tools/pete-2.1.1/et_vector.hpp
@@ -31,7 +31,23 @@
 #include "PETE/PETE.h"
 #include <vector>
 
+// gcc's '-Weffc++' flags user-defined boolean AND and OR operators
+// because they cannot implement short-circuit evaluation. Although
+// Meyers's "Never overload &&, ||, or ," is a generally sound rule
+// for scalar classes, it doesn't make sense for containers, where
+// short-circuit evaluation is not possible anyway. Presumably this
+// warning would be issued for std::valarray::operator||() and &&(),
+// except that they're standard. Similarly, it would issued here for
+// PETE's || and && operators, except for the pragma.
+
+#if defined __GNUC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Weffc++"
+#endif // defined __GNUC__
 #include "et_vector_operators.hpp"
+#if defined __GNUC__
+#   pragma GCC diagnostic pop
+#endif // defined __GNUC__
 
 /// Create vector-iterator leaves.
 
diff --git a/workhorse.make b/workhorse.make
index bfef423..8c3a276 100644
--- a/workhorse.make
+++ b/workhorse.make
@@ -552,6 +552,7 @@ currency_test.o: gcc_common_extra_warnings += \
 
 $(boost_filesystem_objects): gcc_common_extra_warnings += \
   -Wno-deprecated-declarations \
+  -Wno-effc++ \
   -Wno-unused-macros \
   -Wno-unused-parameter \
   -Wno-zero-as-null-pointer-constant \
@@ -559,6 +560,7 @@ $(boost_filesystem_objects): gcc_common_extra_warnings += \
 $(boost_regex_objects): gcc_common_extra_warnings += \
   -Wno-conversion \
   -Wno-duplicated-branches \
+  -Wno-effc++ \
   -Wno-implicit-fallthrough \
   -Wno-register \
   -Wno-shadow \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]