summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2022-07-31 12:56:59 +0200
committerAkim Demaille <akim.demaille@gmail.com>2022-07-31 12:56:59 +0200
commitcf686be382ae70e69fc147768132e9334dc27814 (patch)
tree46bd851a25b40ef41eb7f514a6aa2cbf36c0b3f4
parentc70b68c60d821f200bd3640b236437eae7085b76 (diff)
downloadbison-cf686be382ae70e69fc147768132e9334dc27814.tar.gz
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.
-rw-r--r--configure.ac1
-rw-r--r--tests/cxx-type.at28
2 files changed, 15 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac
index 2f848879..08ea7cdf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,6 +129,7 @@ if test "$enable_gcc_warnings" = yes; then
-Wformat -Wimplicit-fallthrough -Wmismatched-dealloc -Wnull-dereference
-Wno-sign-compare -Wno-tautological-constant-out-of-range-compare
-Wpointer-arith -Wshadow -Wstrict-aliasing
+ -Wunused-but-set-variable
-Wwrite-strings
-wr188 -wr2259 -wr3179'
warn_c='-Wbad-function-cast
diff --git a/tests/cxx-type.at b/tests/cxx-type.at
index 4b2d8ed3..4ebbf503 100644
--- a/tests/cxx-type.at
+++ b/tests/cxx-type.at
@@ -148,13 +148,13 @@ main (int argc, char **argv)
]AT_YYERROR_DEFINE[
]AT_YYLEX_PROTOTYPE[
-{
+{]AT_LOCATION_IF([[
static int lineNum = 1;
static int colNum = 0;
-
-#if YYPURE
+]])[
+#if YYPURE]AT_LOCATION_IF([[
# undef yylloc
-# define yylloc (*llocp)
+# define yylloc (*llocp)]])[
# undef yylval
# define yylval (*lvalp)
#endif
@@ -168,15 +168,15 @@ main (int argc, char **argv)
{
case EOF:
return 0;
- case '\t':
- colNum = (colNum + 7) & ~7;
+ case '\t':]AT_LOCATION_IF([[
+ colNum = (colNum + 7) & ~7;]])[
break;
- case ' ': case '\f':
- colNum += 1;
+ case ' ': case '\f':]AT_LOCATION_IF([[
+ colNum += 1;]])[
break;
- case '\n':
+ case '\n':]AT_LOCATION_IF([[
lineNum += 1;
- colNum = 0;
+ colNum = 0;]])[
break;
default:
{
@@ -190,8 +190,8 @@ main (int argc, char **argv)
do
{
- buffer[i++] = YY_CAST (char, c);
- colNum += 1;
+ buffer[i++] = YY_CAST (char, c);]AT_LOCATION_IF([[
+ colNum += 1;]])[
assert (i != sizeof buffer - 1);
c = getchar ();
}
@@ -203,8 +203,8 @@ main (int argc, char **argv)
yylval = new_term (strdup (buffer));
}
else
- {
- colNum += 1;
+ {]AT_LOCATION_IF([[
+ colNum += 1;]])[
tok = c;
yylval = YY_NULLPTR;
}]AT_LOCATION_IF([[