Skip to content

Commit 8c6f16c

Browse files
committed
warnings: enable -Wuseless-cast, and eliminate warnings
Prompted by Frank Heckenbach. https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00016.html. * configure.ac (warn_cxx): Add -Wuseless-cast. * data/skeletons/c.m4 (b4_attribute_define): Define YY_IGNORE_USELESS_CAST_BEGIN and YY_IGNORE_USELESS_CAST_END. * data/skeletons/glr.c (YY_FPRINTF): New, replaces YYFPRINTF, wrapped with YY_IGNORE_USELESS_CAST_BEGIN and YY_IGNORE_USELESS_CAST_END. (YY_DPRINTF): Likewise. * tests/actions.at: Remove useless cast. * tests/headers.at: Adjust.
1 parent 9e9e492 commit 8c6f16c

File tree

7 files changed

+145
-98
lines changed

7 files changed

+145
-98
lines changed

TODO

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
* Bison 3.5
2+
** Deprecate YYPRINT
3+
The doc shows it too much.
4+
5+
** glr.c: parse.assert
6+
There are many assertions in glr.c that are there to check the skeleton
7+
itself, not the user code. So it should be under the control of
8+
parse.assert.
9+
10+
** java, d: error.verbose
11+
The code checks dynamically for error.verbose. It should be controlled by
12+
M4.
13+
214
** doc
315
I feel its ugly to use the GNU style to declare functions in the doc. It
416
generates tons of white space in the page, and may contribute to bad page

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ if test "$enable_gcc_warnings" = yes; then
108108
-Wwrite-strings'
109109
warn_c='-Wbad-function-cast -Wstrict-prototypes'
110110
warn_cxx='-Wextra-semi -Wnoexcept -Wold-style-cast -Wundefined-func-template
111+
-Wuseless-cast
111112
-Wweak-vtables'
112113
# Warnings for the test suite only.
113114
#

data/skeletons/c.m4

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,19 +327,30 @@ m4_define([b4_attribute_define],
327327
328328
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
329329
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
330-
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
331-
_Pragma ("GCC diagnostic push") \
332-
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
330+
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
331+
_Pragma ("GCC diagnostic push") \
332+
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
333333
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
334-
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
334+
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
335335
_Pragma ("GCC diagnostic pop")
336+
# if defined __cplusplus
337+
# define YY_IGNORE_USELESS_CAST_BEGIN \
338+
_Pragma ("GCC diagnostic push") \
339+
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
340+
# define YY_IGNORE_USELESS_CAST_END \
341+
_Pragma ("GCC diagnostic pop")
342+
# endif
336343
#else
337344
# define YY_INITIAL_VALUE(Value) Value
338345
#endif
339346
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
340347
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
341348
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
342349
#endif
350+
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
351+
# define YY_IGNORE_USELESS_CAST_BEGIN
352+
# define YY_IGNORE_USELESS_CAST_END
353+
#endif
343354
#ifndef YY_INITIAL_VALUE
344355
# define YY_INITIAL_VALUE(Value) /* Nothing. */
345356
#endif

0 commit comments

Comments
 (0)