[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/9] glr2.cc: remove C-style casts
From: |
Akim Demaille |
Subject: |
[PATCH 2/9] glr2.cc: remove C-style casts |
Date: |
Sat, 12 Sep 2020 16:51:48 +0200 |
From: Valentin Tolmer <valentin.tolmer@gmail.com>
* data/skeletons/glr2.cc: here.
---
TODO | 8 --------
data/skeletons/glr2.cc | 18 +++++-------------
2 files changed, 5 insertions(+), 21 deletions(-)
diff --git a/TODO b/TODO
index eecde20a..c9321ecb 100644
--- a/TODO
+++ b/TODO
@@ -165,14 +165,6 @@ 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 \
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index f115dcc0..39eb8b36 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -144,14 +144,6 @@ 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 \
@@ -444,7 +436,7 @@ m4_define([b4_lhs_value],
# -----------------------------
# See README.
m4_define([b4_rhs_data],
-[((yyGLRStackItem const *)yyvsp)@{YYFILL (b4_subtract([$2],
[$1]))@}.getState()])
+[(static_cast<yyGLRStackItem const *>(yyvsp))@{YYFILL (b4_subtract([$2],
[$1]))@}.getState()])
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
@@ -1262,20 +1254,20 @@ struct yyGLRStackItem {
yyGLRState& getState() {
YYDASSERT(isState());
- return *(yyGLRState*)&raw_;
+ return *reinterpret_cast<yyGLRState*>(&raw_);
}
const yyGLRState& getState() const {
YYDASSERT(isState());
- return *(yyGLRState*)&raw_;
+ return *reinterpret_cast<const yyGLRState*>(&raw_);
}
yySemanticOption& getOption() {
YYDASSERT(!isState());
- return *(yySemanticOption*)&raw_;
+ return *reinterpret_cast<yySemanticOption*>(&raw_);
}
const yySemanticOption& getOption() const {
YYDASSERT(!isState());
- return *(yySemanticOption*)&raw_;
+ return *reinterpret_cast<const yySemanticOption*>(&raw_);
}
bool isState() const {
return isState_;
--
2.28.0
- [PATCH 0/9] glr2.cc: warnings and style, Akim Demaille, 2020/09/12
- [PATCH 1/9] glr2.cc: add copy constructor to yyGLRStackItem, Akim Demaille, 2020/09/12
- [PATCH 2/9] glr2.cc: remove C-style casts,
Akim Demaille <=
- [PATCH 3/9] glr2.cc: remove usage of PTRDIFF_MAX, Akim Demaille, 2020/09/12
- [PATCH 4/9] glr2.cc: move StrongIndexAlias into the namespace, Akim Demaille, 2020/09/12
- [PATCH 5/9] glr2.cc: coding style changes, Akim Demaille, 2020/09/12
- [PATCH 6/9] glr2.cc: fix GCC10 warning, Akim Demaille, 2020/09/12
- [PATCH 7/9] glr2.cc: formatting changes, Akim Demaille, 2020/09/12
- [PATCH 8/9] glr2.cc: get rid of the C indirection for yy_symbol_print, Akim Demaille, 2020/09/12
- [PATCH 9/9] glr2.cc: address warnings with G++ 4.8, Akim Demaille, 2020/09/12