From 2bb6340fa9838b7c1ce2e7673c64e5e9840d59f1 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 11 Sep 2021 10:06:13 +0200 Subject: tests: let yacc's yyerror take its argument as a const string Some of yacc error messages are const strings; it makes no sense for yyerror to take a 'char *', it should be a 'const char *' as POSIX now requires. Fixes all the failures reported by Kiyoshi Kanazawa. See bug#50469 . * t/cond35.sh, t/silent-many-languages.sh, t/silent-yacc-headers.sh, * t/silent-yacc.sh, t/subpkg-yacc.sh, t/suffix10.tap, t/yacc-basic.sh, * t/yacc-clean.sh, t/yacc-d-basic.sh, t/yacc-d-vpath.sh, * t/yacc-deleted-headers.sh, t/yacc-depend.sh, t/yacc-depend2.sh, * t/yacc-dist-nobuild-subdir.sh, t/yacc-dist-nobuild.sh, t/yacc-dry.sh, * t/yacc-line.sh, t/yacc-misc.sh, t/yacc-mix-c-cxx.sh, t/yacc-nodist.sh, * t/yacc-pr204.sh, t/yacc-subdir.sh, t/yacc-vpath.sh, * t/yflags-cmdline-override.sh, t/yflags-force-override.sh (yyerror): From 'char *' to 'const char *'. Enforce consistency: prefer '{}' to '{ return; }'. --- t/cond35.sh | 2 +- t/silent-many-languages.sh | 2 +- t/silent-yacc-headers.sh | 2 +- t/silent-yacc.sh | 2 +- t/subpkg-yacc.sh | 2 +- t/suffix10.tap | 2 +- t/yacc-basic.sh | 2 +- t/yacc-bison-skeleton.sh | 2 +- t/yacc-clean-cxx.sh | 2 +- t/yacc-clean.sh | 2 +- t/yacc-cxx.sh | 2 +- t/yacc-d-basic.sh | 2 +- t/yacc-d-vpath.sh | 6 +++--- t/yacc-deleted-headers.sh | 4 ++-- t/yacc-depend.sh | 2 +- t/yacc-depend2.sh | 2 +- t/yacc-dist-nobuild-subdir.sh | 2 +- t/yacc-dist-nobuild.sh | 2 +- t/yacc-dry.sh | 2 +- t/yacc-line.sh | 2 +- t/yacc-misc.sh | 4 ++-- t/yacc-mix-c-cxx.sh | 6 +++--- t/yacc-nodist.sh | 2 +- t/yacc-pr204.sh | 2 +- t/yacc-subdir.sh | 2 +- t/yacc-vpath.sh | 6 +++--- t/yflags-cmdline-override.sh | 2 +- t/yflags-force-override.sh | 2 +- 28 files changed, 36 insertions(+), 36 deletions(-) diff --git a/t/cond35.sh b/t/cond35.sh index 786bb3cf5..37a25eae3 100644 --- a/t/cond35.sh +++ b/t/cond35.sh @@ -73,7 +73,7 @@ END cat > tparse.y << 'END' %{ -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %token EOF %% diff --git a/t/silent-many-languages.sh b/t/silent-many-languages.sh index edb59e7c9..9361b2bf8 100644 --- a/t/silent-many-languages.sh +++ b/t/silent-many-languages.sh @@ -188,7 +188,7 @@ EOF cat > foo6.y <<'EOF' %{ extern int yylex (void); -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %token EOF %% diff --git a/t/silent-yacc-headers.sh b/t/silent-yacc-headers.sh index c10fc5cc4..0582973f5 100644 --- a/t/silent-yacc-headers.sh +++ b/t/silent-yacc-headers.sh @@ -39,7 +39,7 @@ EOF cat > parse.y <<'EOF' %{ -void yyerror (char *s) { return; } +void yyerror (const char *s) {} int yylex (void) { return 0; } int main (void) { return 0; } %} diff --git a/t/silent-yacc.sh b/t/silent-yacc.sh index d11fc2ab2..3254d4014 100644 --- a/t/silent-yacc.sh +++ b/t/silent-yacc.sh @@ -50,7 +50,7 @@ EOF cat > foo.y <<'EOF' %{ -void yyerror (char *s) { return; } +void yyerror (const char *s) {} int yylex (void) { return 0; } int main (void) { return 0; } %} diff --git a/t/subpkg-yacc.sh b/t/subpkg-yacc.sh index eac56cb1f..9e31c5151 100644 --- a/t/subpkg-yacc.sh +++ b/t/subpkg-yacc.sh @@ -88,7 +88,7 @@ EOF cat > lib/foo.y << 'END' %{ int yylex (void) { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% foobar : 'f' 'o' 'o' 'b' 'a' 'r' {}; diff --git a/t/suffix10.tap b/t/suffix10.tap index 2258120e7..d233c6c21 100644 --- a/t/suffix10.tap +++ b/t/suffix10.tap @@ -39,7 +39,7 @@ libfoo_la_SOURCES = foo.x_ :; { echo '/* autogenerated */' \ && echo '%{' \ && echo 'int yylex () {return 0;}' \ - && echo 'void yyerror (char *s) {}' \ + && echo 'void yyerror (const char *s) {}' \ && echo '%}' \ && echo '%%' \ && echo "foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};" \ diff --git a/t/yacc-basic.sh b/t/yacc-basic.sh index cfbaa1957..d50157099 100644 --- a/t/yacc-basic.sh +++ b/t/yacc-basic.sh @@ -42,7 +42,7 @@ cat > parse.y << 'END' #include #include int yylex () { return getchar (); } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% a : 'a' { exit(0); }; diff --git a/t/yacc-bison-skeleton.sh b/t/yacc-bison-skeleton.sh index 60e85dd85..6069489da 100644 --- a/t/yacc-bison-skeleton.sh +++ b/t/yacc-bison-skeleton.sh @@ -44,7 +44,7 @@ void yyerror (const char *s); foobar : 'f' 'o' 'o' 'b' 'a' 'r' {}; %% int yylex () { return 0; } -void yyerror (const char *s) { return; } +void yyerror (const char *s) {} END cat > foo.c << 'END' diff --git a/t/yacc-clean-cxx.sh b/t/yacc-clean-cxx.sh index fe2795894..811d46939 100644 --- a/t/yacc-clean-cxx.sh +++ b/t/yacc-clean-cxx.sh @@ -70,7 +70,7 @@ cat > sub1/parsefoo.yxx << 'END' #include // "std::" qualification required by Sun C++ 5.9. int yylex (void) { return std::getchar (); } -void yyerror (const char *s) { return; } +void yyerror (const char *s) {} %} %% x : 'x' { }; diff --git a/t/yacc-clean.sh b/t/yacc-clean.sh index 9ea13a704..c248e5c89 100644 --- a/t/yacc-clean.sh +++ b/t/yacc-clean.sh @@ -66,7 +66,7 @@ END cat > sub1/parse.y << 'END' %{ int yylex () { return (getchar ()); } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% x : 'x' { }; diff --git a/t/yacc-cxx.sh b/t/yacc-cxx.sh index 0e163eb44..b9dcd458b 100644 --- a/t/yacc-cxx.sh +++ b/t/yacc-cxx.sh @@ -48,7 +48,7 @@ cat > parse1.yy << 'END' #include // "std::" qualification required by Sun C++ 5.9. int yylex (void) { return std::getchar (); } -void yyerror (const char *s) { return; } +void yyerror (const char *s) {} %} %% a : 'a' { exit(0); }; diff --git a/t/yacc-d-basic.sh b/t/yacc-d-basic.sh index 66c11063e..b468d5532 100644 --- a/t/yacc-d-basic.sh +++ b/t/yacc-d-basic.sh @@ -48,7 +48,7 @@ cat > foo/parse.y << 'END' %{ #include "parse.h" int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% x : 'x' {}; diff --git a/t/yacc-d-vpath.sh b/t/yacc-d-vpath.sh index e0fb951f2..86ae07b0c 100644 --- a/t/yacc-d-vpath.sh +++ b/t/yacc-d-vpath.sh @@ -41,7 +41,7 @@ END cat > parse.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %token FOOBAR %% @@ -74,7 +74,7 @@ $sleep cat > ../parse.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %token FUBAR %% @@ -94,7 +94,7 @@ $sleep cat > ../parse.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %token MAUDE %% diff --git a/t/yacc-deleted-headers.sh b/t/yacc-deleted-headers.sh index 766caac5c..5b661d1e5 100644 --- a/t/yacc-deleted-headers.sh +++ b/t/yacc-deleted-headers.sh @@ -56,7 +56,7 @@ cat > parse1.y << 'END' %{ #include "parse1.h" int yylex () { return 0; } -void yyerror (char *s) { return; } +void yyerror (const char *s) {} %} %token ZARDOZ %% @@ -81,7 +81,7 @@ sed 's/"parse1\.h"/"parse3.h"/' main1.c > main3.c cat > parse4.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) { return; } +void yyerror (const char *s) {} %} %% x : 'x' {}; diff --git a/t/yacc-depend.sh b/t/yacc-depend.sh index 27c704b3d..dc82a316a 100644 --- a/t/yacc-depend.sh +++ b/t/yacc-depend.sh @@ -36,7 +36,7 @@ END cat > foo.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) { return; } +void yyerror (const char *s) {} %} %token TOKEN %% diff --git a/t/yacc-depend2.sh b/t/yacc-depend2.sh index ce730f42b..c2b1b9be5 100644 --- a/t/yacc-depend2.sh +++ b/t/yacc-depend2.sh @@ -42,7 +42,7 @@ END cat > foo.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) { return; } +void yyerror (const char *s) {} %} %token TOKEN %% diff --git a/t/yacc-dist-nobuild-subdir.sh b/t/yacc-dist-nobuild-subdir.sh index c918c3996..8b15d2c2a 100644 --- a/t/yacc-dist-nobuild-subdir.sh +++ b/t/yacc-dist-nobuild-subdir.sh @@ -36,7 +36,7 @@ mkdir sub cat > sub/parse.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) { return; } +void yyerror (const char *s) {} %} %% x : 'x' {}; diff --git a/t/yacc-dist-nobuild.sh b/t/yacc-dist-nobuild.sh index 5e1a2a70a..f4d3fbcb2 100644 --- a/t/yacc-dist-nobuild.sh +++ b/t/yacc-dist-nobuild.sh @@ -37,7 +37,7 @@ END cat > parse.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% foobar : 'f' 'o' 'o' 'b' 'a' 'r' {}; diff --git a/t/yacc-dry.sh b/t/yacc-dry.sh index c9c1aa2e0..43e1422a6 100644 --- a/t/yacc-dry.sh +++ b/t/yacc-dry.sh @@ -38,7 +38,7 @@ END cat > parse.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% foobar : 'f' 'o' 'o' 'b' 'a' 'r' {}; diff --git a/t/yacc-line.sh b/t/yacc-line.sh index 10e8a8cd4..ef48d83c5 100644 --- a/t/yacc-line.sh +++ b/t/yacc-line.sh @@ -57,7 +57,7 @@ END cat > zardoz.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) { return; } +void yyerror (const char *s) {} %} %% x : 'x' {}; diff --git a/t/yacc-misc.sh b/t/yacc-misc.sh index 2371a099f..9dc8f9dfd 100644 --- a/t/yacc-misc.sh +++ b/t/yacc-misc.sh @@ -35,7 +35,7 @@ END cat > parse.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% foobar : 'f' 'o' 'o' 'b' 'a' 'r' {}; @@ -45,7 +45,7 @@ END cat > bar.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% fubar : 'f' 'o' 'o' 'b' 'a' 'r' {}; diff --git a/t/yacc-mix-c-cxx.sh b/t/yacc-mix-c-cxx.sh index ad9bf9523..45dffa0d2 100644 --- a/t/yacc-mix-c-cxx.sh +++ b/t/yacc-mix-c-cxx.sh @@ -53,7 +53,7 @@ END cat > p.y <<'END' %{ int yylex (void) { int new = 0; return new; } -void yyerror (char *s) { return; } +void yyerror (const char *s) {} %} %token ZARDOZ %% @@ -85,7 +85,7 @@ cat > parse.yy <<'END' #include #include "parse.hh" int yylex (void) { return 0; } -void yyerror (const char *s) { return; } +void yyerror (const char *s) {} %} %token FOOBAR %% @@ -97,7 +97,7 @@ cat > parse2.y++ <<'END' %{ #include int yylex (void) { return 0; } -void yyerror (const char *s) { return; } +void yyerror (const char *s) {} %} %% x : 'x' {}; diff --git a/t/yacc-nodist.sh b/t/yacc-nodist.sh index 075e07743..3b523e888 100644 --- a/t/yacc-nodist.sh +++ b/t/yacc-nodist.sh @@ -59,7 +59,7 @@ parse.y: :; { : \ && echo "%{" \ && echo "int yylex () { return 0; }" \ - && echo "void yyerror (char *s) {}" \ + && echo "void yyerror (const char *s) {}" \ && echo "%}" \ && echo "%%" \ && echo "maude : 'm' 'a' 'u' 'd' 'e' {}"; \ diff --git a/t/yacc-pr204.sh b/t/yacc-pr204.sh index 9606f7b3d..e07f5e5c9 100644 --- a/t/yacc-pr204.sh +++ b/t/yacc-pr204.sh @@ -51,7 +51,7 @@ EOF cat > parse.y << 'END' %{ int yylex () {return 0;} -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% maude : 'm' 'a' 'u' 'd' 'e' {}; diff --git a/t/yacc-subdir.sh b/t/yacc-subdir.sh index 5f3862187..879b433c6 100644 --- a/t/yacc-subdir.sh +++ b/t/yacc-subdir.sh @@ -49,7 +49,7 @@ mkdir foo cat > foo/parse.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% foobar : 'f' 'o' 'o' 'b' 'a' 'r' {}; diff --git a/t/yacc-vpath.sh b/t/yacc-vpath.sh index f9bb719da..5481d9646 100644 --- a/t/yacc-vpath.sh +++ b/t/yacc-vpath.sh @@ -40,7 +40,7 @@ END cat > parse.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% foobar : 'f' 'o' 'o' 'b' 'a' 'r' {}; @@ -67,7 +67,7 @@ $sleep cat > ../parse.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% fubar : 'f' 'o' 'o' 'b' 'a' 'r' {}; @@ -85,7 +85,7 @@ $sleep cat > ../parse.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) {} +void yyerror (const char *s) {} %} %% maude : 'm' 'a' 'u' 'd' 'e' {}; diff --git a/t/yflags-cmdline-override.sh b/t/yflags-cmdline-override.sh index eaee47849..63d31fbfa 100644 --- a/t/yflags-cmdline-override.sh +++ b/t/yflags-cmdline-override.sh @@ -43,7 +43,7 @@ END cat > foo.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) { return; } +void yyerror (const char *s) {} int main () { return 0; } %} %% diff --git a/t/yflags-force-override.sh b/t/yflags-force-override.sh index 2d5cb55e1..1346c1259 100644 --- a/t/yflags-force-override.sh +++ b/t/yflags-force-override.sh @@ -37,7 +37,7 @@ END cat > foo.y << 'END' %{ int yylex () { return 0; } -void yyerror (char *s) { return; } +void yyerror (const char *s) {} int main () { return 0; } %} %% -- cgit v1.2.1