Skip to content

Commit

Permalink
warnings: enable -Wuseless-cast, and eliminate warnings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akimd committed Dec 5, 2019
1 parent 9e9e492 commit 8c6f16c
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 98 deletions.
12 changes: 12 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
* Bison 3.5
** Deprecate YYPRINT
The doc shows it too much.

** glr.c: parse.assert
There are many assertions in glr.c that are there to check the skeleton
itself, not the user code. So it should be under the control of
parse.assert.

** java, d: error.verbose
The code checks dynamically for error.verbose. It should be controlled by
M4.

** doc
I feel its ugly to use the GNU style to declare functions in the doc. It
generates tons of white space in the page, and may contribute to bad page
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ if test "$enable_gcc_warnings" = yes; then
-Wwrite-strings'
warn_c='-Wbad-function-cast -Wstrict-prototypes'
warn_cxx='-Wextra-semi -Wnoexcept -Wold-style-cast -Wundefined-func-template
-Wuseless-cast
-Wweak-vtables'
# Warnings for the test suite only.
#
Expand Down
19 changes: 15 additions & 4 deletions data/skeletons/c.m4
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,30 @@ m4_define([b4_attribute_define],
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
# if defined __cplusplus
# define YY_IGNORE_USELESS_CAST_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
# define YY_IGNORE_USELESS_CAST_END \
_Pragma ("GCC diagnostic pop")
# endif
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
Expand Down
Loading

0 comments on commit 8c6f16c

Please sign in to comment.