bison-patches
[Top][All Lists]
Advanced

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

glr2.cc: avoid warnings about long long


From: Akim Demaille
Subject: glr2.cc: avoid warnings about long long
Date: Sun, 30 Aug 2020 20:04:58 +0200

commit e2484242c51ae8d686e8e7cd9810b742aeb31518
Author: Akim Demaille <akim.demaille@gmail.com>
Date:   Sun Aug 30 19:58:14 2020 +0200

    glr2.cc: avoid warnings about long long
    
    * data/skeletons/glr2.cc: Disable the warning before triggering it.

diff --git a/TODO b/TODO
index b8b2befb..4fea8c81 100644
--- a/TODO
+++ b/TODO
@@ -151,8 +151,35 @@ Line -1 and -3 should mention CATEGORIE, not CATEGORY.
 
 * Bison 3.8
 ** Rewrite glr.cc
+*** glr.c
 Get rid of scaffolding in glr.c.
 
+*** pragmas in glr2.cc
+Remove the pragmas that disable some warnings:
+
+    // This skeleton is based on C, yet compiles it as C++.
+    // So expect warnings about C style casts.
+    #if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__
+    # pragma clang diagnostic ignored "-Wold-style-cast"
+    #elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
+    # pragma GCC diagnostic ignored "-Wold-style-cast"
+    #endif
+
+    // On MacOS, PTRDIFF_MAX is defined as long long, which Clang's
+    // -pedantic reports as being a C++11 extension.
+    #if defined __APPLE__ && YY_CPLUSPLUS < 201103L \
+        && defined __clang__ && 4 <= __clang_major__
+    # pragma clang diagnostic ignored "-Wc++11-long-long"
+    #endif
+
+We should use clean C++ code.
+
+*** namespaces in glr2.cc
+StrongIndexAlias should be in the parser's namespace.  Possibly even an
+inner class.
+
+
+* Chains
 ** Unit rules / Injection rules (Akim Demaille)
 Maybe we could expand unit rules (or "injections", see
 https://homepages.cwi.nl/~daybuild/daily-books/syntax/2-sdf/sdf.html), i.e.,
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 09f70e92..fdd5833b 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -162,6 +162,21 @@ b4_percent_code_get([[requires]])[
 ]b4_cast_define[
 ]b4_null_define[
 
+// This skeleton is based on C, yet compiles it as C++.
+// So expect warnings about C style casts.
+#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__
+# pragma clang diagnostic ignored "-Wold-style-cast"
+#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
+# pragma GCC diagnostic ignored "-Wold-style-cast"
+#endif
+
+// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's
+// -pedantic reports as being a C++11 extension.
+#if defined __APPLE__ && YY_CPLUSPLUS < 201103L \
+    && defined __clang__ && 4 <= __clang_major__
+# pragma clang diagnostic ignored "-Wc++11-long-long"
+#endif
+
 template <typename Parameter>
 class StrongIndexAlias
 {
@@ -228,22 +243,6 @@ class StrongIndexAlias
   std::ptrdiff_t value_;
 };
 
-
-// This skeleton is based on C, yet compiles it as C++.
-// So expect warnings about C style casts.
-#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__
-# pragma clang diagnostic ignored "-Wold-style-cast"
-#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
-# pragma GCC diagnostic ignored "-Wold-style-cast"
-#endif
-
-// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's
-// -pedantic reports as being a C++11 extension.
-#if defined __APPLE__ && YY_CPLUSPLUS < 201103L \
-    && defined __clang__ && 4 <= __clang_major__
-# pragma clang diagnostic ignored "-Wc++11-long-long"
-#endif
-
 // Whether we are compiled with exception support.
 #ifndef YY_EXCEPTIONS
 # if defined __GNUC__ && !defined __EXCEPTIONS




reply via email to

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