From 422a7073b87ef1845cdb9f98e0ed2d7613a73503 Mon Sep 17 00:00:00 2001
From: Sam Yates <sam@quux.dropbear.id.au>
Date: Fri, 10 Jun 2016 20:57:34 +0200
Subject: [PATCH] Address clang compiler warnings

Clang (by default) objects to the omission of parentheses in
expressios such as a && b || c, and also to brace elision
in aggregate initialisation. The latter complicates initialisation
of e.g. std::array. GCC has not turned this warning on for
that reason, and there is an open issue for this for clang:
https://llvm.org/bugs/show_bug.cgi?id=21629

* Add parentheses to resolve logical parentheses warning
* Suppress missing-braces diagnostic in test_optional.cpp
---
 src/util/optional.hpp   | 2 +-
 tests/test_optional.cpp | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/util/optional.hpp b/src/util/optional.hpp
index f1fb805b..a3c2da99 100644
--- a/src/util/optional.hpp
+++ b/src/util/optional.hpp
@@ -107,7 +107,7 @@ namespace detail {
 
         template <typename Y>
         bool operator==(const optional<Y> &o) const {
-            return set && o.set && ref()==o.ref() || !set && !o.set;
+            return (set && o.set && ref()==o.ref()) || (!set && !o.set);
         }
 
         void reset() {
diff --git a/tests/test_optional.cpp b/tests/test_optional.cpp
index e3ca5ecb..64df6cac 100644
--- a/tests/test_optional.cpp
+++ b/tests/test_optional.cpp
@@ -5,6 +5,11 @@
 #include "gtest.h"
 #include "util/optional.hpp"
 
+#if defined(__clang__)
+// refer: https://llvm.org/bugs/show_bug.cgi?id=21629
+#pragma clang diagnostic ignored "-Wmissing-braces"
+#endif
+
 using namespace nest::mc::util;
 
 TEST(optionalm,ctors) {
-- 
GitLab