mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
warning: avoid warnings about unreachable code
Reported by Uxio Prego. https://lists.gnu.org/archive/html/help-bison/2018-11/msg00031.html We also need to move the unreachable 'goto' to a reachable place, otherwise clang complains about the code being unreachable anyway. See also https://bugs.llvm.org/show_bug.cgi?id=39736. Interestingly, we don't have to apply that trick to `#define YYCDEBUG if (false) std::cerr`, clang does not warn when the code comes from macro expansion. * configure.ac: Use -Wunreachable-code when supported. * data/lalr1.cc, data/yacc.c: Pacify clang's warning about `if (0)` by using a macro. Another possibility was to move this statement to a reachable place. * tests/actions.at, tests/c++.at: Avoid generating unreachable code.
This commit is contained in:
@@ -971,11 +971,11 @@ b4_dollar_popdef])[]dnl
|
||||
| yyerrorlab -- error raised explicitly by YYERROR. |
|
||||
`---------------------------------------------------*/
|
||||
yyerrorlab:
|
||||
/* Pacify compilers like GCC when the user code never invokes
|
||||
YYERROR and the label yyerrorlab therefore never appears in user
|
||||
code. */
|
||||
/* Pacify compilers when the user code never invokes YYERROR and
|
||||
the label yyerrorlab therefore never appears in user code. */
|
||||
if (false)
|
||||
goto yyerrorlab;
|
||||
YYERROR;
|
||||
|
||||
/* Do not reclaim the symbols of the rule whose action triggered
|
||||
this YYERROR. */
|
||||
yypop_ (yylen);
|
||||
|
||||
@@ -1777,11 +1777,10 @@ yyerrlab:
|
||||
| yyerrorlab -- error raised explicitly by YYERROR. |
|
||||
`---------------------------------------------------*/
|
||||
yyerrorlab:
|
||||
/* Pacify compilers like GCC when the user code never invokes
|
||||
YYERROR and the label yyerrorlab therefore never appears in user
|
||||
code. */
|
||||
/* Pacify compilers when the user code never invokes YYERROR and the
|
||||
label yyerrorlab therefore never appears in user code. */
|
||||
if (0)
|
||||
goto yyerrorlab;
|
||||
YYERROR;
|
||||
|
||||
/* Do not reclaim the symbols of the rule whose action triggered
|
||||
this YYERROR. */
|
||||
|
||||
Reference in New Issue
Block a user