Subject: test: Accommodate C23 compilers.

From: Collin Funk <[email-masked]>
Date: Fri, 07 Jun 2024 22:05:49 -0700

In the yacc test I see warnings like this:

main.c:4:10: error: implicit declaration of function ‘yyparse’ [-Wimplicit-function-declaration]
    4 |   return yyparse ();
      |          ^~~~~~~

and some for yylex which is declared, but with an empty parameter list
instead of void.

I assume this is because GCC becoming more strict to conform with C23
requirements. I did these tests with GCC 14.1.

I have attached a patch fixing these tests on my system.

Collin

>From 615faf791ccc2aa744c61bd9f5982ebe225748d4 Mon Sep 17 00:00:00 2001
From: Collin Funk <[email-masked]>
Date: Fri, 7 Jun 2024 21:53:51 -0700
Subject: [PATCH] test: Accommodate C23 compilers.

* t/yacc-deleted-headers.sh: Declare yyparse before use.
* t/yacc-depend.sh: Likewise.
* t/yacc-mix-c-cxx.sh: Likewise.
* t/yacc-d-basic.sh: Likewise. Use void instead of empty parameter list.
* t/yacc-depend2.sh: Likewise.
---
 t/yacc-d-basic.sh         | 3 ++-
 t/yacc-deleted-headers.sh | 1 +
 t/yacc-depend.sh          | 1 +
 t/yacc-depend2.sh         | 3 ++-
 t/yacc-mix-c-cxx.sh       | 2 ++
 5 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/t/yacc-d-basic.sh b/t/yacc-d-basic.sh
index cc076148b..df3cfece1 100644
--- a/t/yacc-d-basic.sh
+++ b/t/yacc-d-basic.sh
@@ -49,7 +49,7 @@ cp foo/Makefile.am baz/Makefile.am
 cat > foo/parse.y << 'END'
 %{
 #include "parse.h"
-int yylex () { return 0; }
+int yylex (void) { return 0; }
 void yyerror (const char *s) {}
 %}
 %%
@@ -69,6 +69,7 @@ sed -e 's/parse\.h/y.tab.h/' <foo/parse.y >bar/parse.y
 
 cat > foo/main.c << 'END'
 #include "parse.h"
+extern int yyparse (void);
 int main ()
 {
   return yyparse ();
diff --git a/t/yacc-deleted-headers.sh b/t/yacc-deleted-headers.sh
index 81957eb86..682dd5f5d 100644
--- a/t/yacc-deleted-headers.sh
+++ b/t/yacc-deleted-headers.sh
@@ -68,6 +68,7 @@ END
 
 cat > main1.c << 'END'
 #include "parse1.h"
+extern int yyparse (void);
 int main (void)
 {
   return ZARDOZ + yyparse ();
diff --git a/t/yacc-depend.sh b/t/yacc-depend.sh
index e5ad6870c..1f67ecac4 100644
--- a/t/yacc-depend.sh
+++ b/t/yacc-depend.sh
@@ -48,6 +48,7 @@ END
 
 cat > main.c << 'END'
 #include "foo.h"
+extern int yyparse (void);
 int main(void)
 {
   return yyparse ();
diff --git a/t/yacc-depend2.sh b/t/yacc-depend2.sh
index f0529294e..896b86df4 100644
--- a/t/yacc-depend2.sh
+++ b/t/yacc-depend2.sh
@@ -43,7 +43,7 @@ END
 
 cat > foo.y << 'END'
 %{
-int yylex () { return 0; }
+int yylex (void) { return 0; }
 void yyerror (const char *s) {}
 %}
 %token TOKEN
@@ -54,6 +54,7 @@ END
 
 cat > main.c << 'END'
 #include "foo.h"
+extern int yyparse (void);
 int main(void)
 {
   return yyparse ();
diff --git a/t/yacc-mix-c-cxx.sh b/t/yacc-mix-c-cxx.sh
index d454fe244..021b4223d 100644
--- a/t/yacc-mix-c-cxx.sh
+++ b/t/yacc-mix-c-cxx.sh
@@ -71,6 +71,7 @@ END
 
 cat > 1.c <<'END'
 #include "p.h"
+extern int yyparse (void);
 int main ()
 {
     int new = ZARDOZ;
@@ -80,6 +81,7 @@ int main ()
 END
 
 cat > 2.c <<'END'
+extern int yyparse (void);
 int main ()
 {
     int yyparse ();
-- 
2.45.2