lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Recursive macro?


From: Vadim Zeitlin
Subject: Re: [lmi] Recursive macro?
Date: Sat, 9 Jul 2022 18:31:38 +0200

On Fri, 8 Jul 2022 02:27:04 +0000 Greg Chicares <gchicares@sbcglobal.net> wrote:

GC> In file included from /opt/lmi/src/lmi/regex_test.cpp:29:
GC> /opt/lmi/src/lmi/pcre_regex.hpp:256:31: error: disabled expansion of 
recursive macro [-Werror,-Wdisabled-macro-expansion]
GC>             (reinterpret_cast<PCRE2_SPTR>(pattern.data())
GC>                               ^
GC> /usr/include/pcre2.h:806:50: note: expanded from macro 'PCRE2_SPTR'
GC> #define PCRE2_SPTR                  PCRE2_SUFFIX(PCRE2_SPTR)
GC>                                                  ^
GC> 
GC> Any thoughts?

 No non-trivial ones, i.e. nothing else comes to mind except disabling this
warning before pcre2.h inclusion and re-enabling it after it, using
push/pop diagnostics pragmas:

---------------------------------- >8 --------------------------------------
diff --git a/pcre_regex.hpp b/pcre_regex.hpp
index 4034c9240..4363bd689 100644
--- a/pcre_regex.hpp
+++ b/pcre_regex.hpp
@@ -28,6 +28,13 @@
 // system, but not necessarily otherwise.
 #if defined LMI_POSIX

+// Avoid spurious warnings about "recursive" expansion of PCRE2_SPTR (which
+// isn't really recursive at all).
+#if defined LMI_CLANG
+#   pragma clang diagnostic push
+#   pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
+#endif // defined LMI_CLANG
+
 // UTF-8 everywhere; UTF-[^8] nowhere.
 #define PCRE2_CODE_UNIT_WIDTH 8
 #include <pcre2.h>
@@ -575,6 +582,10 @@ search_all(std::string_view const& s, regex const& rx)

 } // namespace pcre

+#if defined LMI_CLANG
+#   pragma clang diagnostic pop
+#endif // defined LMI_CLANG
+
 #endif // defined LMI_POSIX

 #endif // pcre_regex_hpp
---------------------------------- >8 --------------------------------------

 FWIW this looks like a compiler bug to me, but, whether it is or not, I
don't see what else could we possibly do about it, if we want to enable
this warning.

 Regards,
VZ

Attachment: pgpwu3l5KT46W.pgp
Description: PGP signature


reply via email to

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