bison-patches
[Top][All Lists]
Advanced

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

doc: work around warnings when Flex C output is compiled in C++


From: Akim Demaille
Subject: doc: work around warnings when Flex C output is compiled in C++
Date: Sat, 16 Nov 2019 15:48:57 +0100

commit dbd6975b5c0a99492396b759cae8a7e12d226846
Author: Akim Demaille <address@hidden>
Date:   Sat Nov 16 10:05:29 2019 +0100

    doc: work around warnings when Flex C output is compiled in C++
    
    * doc/bison.texi (calc++/scanner.ll): here.
    While at it, clarify clang vs. warnings.

diff --git a/doc/bison.texi b/doc/bison.texi
index 2baf140c..bace4718 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -12247,17 +12247,27 @@ then the parser's to get the set of defined tokens.
 @comment file: calc++/scanner.ll
 @example
 %@{
+#if defined __clang__
+# define CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
+#endif
+
+// Clang and ICC like to pretend they are GCC.
+#if defined __GNUC__ && !defined __clang__ && !defined __ICC
+# define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+#endif
+
 // Pacify warnings in yy_init_buffer (observed with Flex 2.6.4)
-// and GCC 6.4.0, 7.3.0.
-#if defined __GNUC__ && !defined __clang__ && 6 <= __GNUC__
+// and GCC 6.4.0, 7.3.0 with -O3.
+#if defined GCC_VERSION && 600 <= GCC_VERSION
 # pragma GCC diagnostic ignored "-Wnull-dereference"
 #endif
 
 // This example uses Flex's C backend, yet compiles it as C++.
 // So expect warnings about C style casts and NULL.
-#if defined __clang__
+#if defined CLANG_VERSION && 500 <= CLANG_VERSION
+# pragma clang diagnostic ignored "-Wold-style-cast"
 # pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
-#elif defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+#elif defined GCC_VERSION && 407 <= GCC_VERSION
 # pragma GCC diagnostic ignored "-Wold-style-cast"
 # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
 #endif
@@ -12272,27 +12282,27 @@ then the parser's to get the set of defined tokens.
 //   * @param line_number
 //     ~~~~~~~~~~~~~~~~~^
 //  1 error generated.
-#if FLEX_VERSION < 206 && defined __clang__
+#if FLEX_VERSION < 206 && defined CLANG_VERSION
 # pragma clang diagnostic ignored "-Wdocumentation"
 #endif
 
 // Old versions of Flex (2.5.35) use 'register'.  Warnings introduced in
 // GCC 7 and Clang 6.
 #if FLEX_VERSION < 206
-# if defined __clang__ && 6 <= __clang_major__
+# if defined CLANG_VERSION && 600 <= CLANG_VERSION
 #  pragma clang diagnostic ignored "-Wdeprecated-register"
-# elif defined __GNUC__ && 7 <= __GNUC__
+# elif defined GCC_VERSION && 700 <= GCC_VERSION
 #  pragma GCC diagnostic ignored "-Wregister"
 # endif
 #endif
 
 #if FLEX_VERSION < 206
-# if defined __clang__
+# if defined CLANG_VERSION
 #  pragma clang diagnostic ignored "-Wconversion"
 #  pragma clang diagnostic ignored "-Wdocumentation"
 #  pragma clang diagnostic ignored "-Wshorten-64-to-32"
 #  pragma clang diagnostic ignored "-Wsign-conversion"
-# elif defined __GNUC__
+# elif defined GCC_VERSION
 #  pragma GCC diagnostic ignored "-Wconversion"
 #  pragma GCC diagnostic ignored "-Wsign-conversion"
 # endif




reply via email to

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