tests: avoid useless variables

Reported by clang's -Wunused-but-set-variable warning.

* configure.ac (warn_common): Add -Wunused-but-set-variable.
* tests/cxx-type.at: Don't emit location track code when we don't use
locations.
This commit is contained in:
Akim Demaille
2022-07-31 12:56:59 +02:00
parent c70b68c60d
commit cf686be382
2 changed files with 15 additions and 14 deletions

View File

@@ -129,6 +129,7 @@ if test "$enable_gcc_warnings" = yes; then
-Wformat -Wimplicit-fallthrough -Wmismatched-dealloc -Wnull-dereference -Wformat -Wimplicit-fallthrough -Wmismatched-dealloc -Wnull-dereference
-Wno-sign-compare -Wno-tautological-constant-out-of-range-compare -Wno-sign-compare -Wno-tautological-constant-out-of-range-compare
-Wpointer-arith -Wshadow -Wstrict-aliasing -Wpointer-arith -Wshadow -Wstrict-aliasing
-Wunused-but-set-variable
-Wwrite-strings -Wwrite-strings
-wr188 -wr2259 -wr3179' -wr188 -wr2259 -wr3179'
warn_c='-Wbad-function-cast warn_c='-Wbad-function-cast

View File

@@ -148,13 +148,13 @@ main (int argc, char **argv)
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
]AT_YYLEX_PROTOTYPE[ ]AT_YYLEX_PROTOTYPE[
{ {]AT_LOCATION_IF([[
static int lineNum = 1; static int lineNum = 1;
static int colNum = 0; static int colNum = 0;
]])[
#if YYPURE #if YYPURE]AT_LOCATION_IF([[
# undef yylloc # undef yylloc
# define yylloc (*llocp) # define yylloc (*llocp)]])[
# undef yylval # undef yylval
# define yylval (*lvalp) # define yylval (*lvalp)
#endif #endif
@@ -168,15 +168,15 @@ main (int argc, char **argv)
{ {
case EOF: case EOF:
return 0; return 0;
case '\t': case '\t':]AT_LOCATION_IF([[
colNum = (colNum + 7) & ~7; colNum = (colNum + 7) & ~7;]])[
break; break;
case ' ': case '\f': case ' ': case '\f':]AT_LOCATION_IF([[
colNum += 1; colNum += 1;]])[
break; break;
case '\n': case '\n':]AT_LOCATION_IF([[
lineNum += 1; lineNum += 1;
colNum = 0; colNum = 0;]])[
break; break;
default: default:
{ {
@@ -190,8 +190,8 @@ main (int argc, char **argv)
do do
{ {
buffer[i++] = YY_CAST (char, c); buffer[i++] = YY_CAST (char, c);]AT_LOCATION_IF([[
colNum += 1; colNum += 1;]])[
assert (i != sizeof buffer - 1); assert (i != sizeof buffer - 1);
c = getchar (); c = getchar ();
} }
@@ -203,8 +203,8 @@ main (int argc, char **argv)
yylval = new_term (strdup (buffer)); yylval = new_term (strdup (buffer));
} }
else else
{ {]AT_LOCATION_IF([[
colNum += 1; colNum += 1;]])[
tok = c; tok = c;
yylval = YY_NULLPTR; yylval = YY_NULLPTR;
}]AT_LOCATION_IF([[ }]AT_LOCATION_IF([[