From e36593e9608d0437035b631df6b667cd8fa19dbd Mon Sep 17 00:00:00 2001
From: Niels Lohmann <mail@nlohmann.me>
Date: Sun, 20 Jan 2019 11:12:20 +0100
Subject: [PATCH] :hammer: trying code from https://godbolt.org/z/-tLO1K

---
 include/nlohmann/detail/macro_scope.hpp | 12 ++++++++----
 single_include/nlohmann/json.hpp        | 12 ++++++++----
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp
index fdd1aa12..b1bd1484 100644
--- a/include/nlohmann/detail/macro_scope.hpp
+++ b/include/nlohmann/detail/macro_scope.hpp
@@ -38,10 +38,14 @@
 #endif
 
 // allow for portable nodiscard warnings
-#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
-    #define JSON_NODISCARD [[nodiscard]]
-#elif defined(__has_cpp_attribute) && __has_cpp_attribute(gnu::warn_unused_result)
-    #define JSON_NODISCARD [[gnu::warn_unused_result]]
+#if defined(__has_cpp_attribute)
+    #if __has_cpp_attribute(nodiscard)
+        #define JSON_NODISCARD [[nodiscard]]
+    #elif __has_cpp_attribute(gnu::warn_unused_result)
+        #define JSON_NODISCARD [[gnu::warn_unused_result]]
+    #else
+        #define JSON_NODISCARD
+    #endif
 #else
     #define JSON_NODISCARD
 #endif
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index 6570f8d1..70412a18 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -153,10 +153,14 @@ using json = basic_json<>;
 #endif
 
 // allow for portable nodiscard warnings
-#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
-    #define JSON_NODISCARD [[nodiscard]]
-#elif defined(__has_cpp_attribute) && __has_cpp_attribute(gnu::warn_unused_result)
-    #define JSON_NODISCARD [[gnu::warn_unused_result]]
+#if defined(__has_cpp_attribute)
+    #if __has_cpp_attribute(nodiscard)
+        #define JSON_NODISCARD [[nodiscard]]
+    #elif __has_cpp_attribute(gnu::warn_unused_result)
+        #define JSON_NODISCARD [[gnu::warn_unused_result]]
+    #else
+        #define JSON_NODISCARD
+    #endif
 #else
     #define JSON_NODISCARD
 #endif