]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: avoid implicit function declarations.
authorFrédéric Bérat <fberat@redhat.com>
Tue, 29 Aug 2023 18:00:41 +0000 (11:00 -0700)
committerKarl Berry <karl@freefriends.org>
Tue, 29 Aug 2023 18:00:41 +0000 (11:00 -0700)
This patch is from https://bugs.gnu.org/59993 (v2 part 2).

* t/c-demo.sh: This patch is related to an effort to prepare
Automake for future GCC/Clang versions which set c99 as default
standard to be used.

C99 requires that functions be properly declared before use.
This is true for both user functions and standard functions,
e.g., printf.

* t/cond35.sh: Likewise.
* t/dist-vs-built-sources.sh: Likewise.
* t/lex-clean.sh: Likewise.
* t/lex-multiple.sh: Likewise.
* t/lex-nodist.sh: Likewise.
* t/ltcond2.sh: Likewise.
* t/ltconv.sh: Likewise.
* t/subobj-clean-lt-pr10697.sh: Likewise.
* t/subobj-clean-pr10697.sh: Likewise.
* t/tags-pr12372.sh: Likewise.
* t/yacc-basic.sh: Likewise.
* t/yacc-clean.sh: Likewise.
* t/yacc-nodist.sh: Likewise.

This patch is from https://bugs.gnu.org/59993.

14 files changed:
t/c-demo.sh
t/cond35.sh
t/dist-vs-built-sources.sh
t/lex-clean.sh
t/lex-multiple.sh
t/lex-nodist.sh
t/ltcond2.sh
t/ltconv.sh
t/subobj-clean-lt-pr10697.sh
t/subobj-clean-pr10697.sh
t/tags-pr12372.sh
t/yacc-basic.sh
t/yacc-clean.sh
t/yacc-nodist.sh

index 44655195842e28c8ba9ae2da8d32488b26d8087d..ee0d5c3ec45960c2bdbf9a89fc4b64b7639e355d 100644 (file)
@@ -113,6 +113,7 @@ test -f build-aux/compile # We have per-target flags on C sources.
 ./configure --enable-dependency-tracking
 
 cat > src/main.c << 'END'
+#include <stdio.h>
 #include "foo.h"
 #include "bar.h"
 int main (void)
index 8b044644e8551585705decab77f7b4f602b92c9f..a00c9e2802e1f499996acfd5599242cd92563ee7 100644 (file)
@@ -71,6 +71,8 @@ END
 
 cat > tparse.y << 'END'
 %{
+extern int yylex(void);
+
 void yyerror (const char *s) {}
 %}
 %token EOF
index da8c8fb23e65c42d15fdd7d8f1c59a39ee63c70c..4c73d53b04fef96baebde41142d34cd029a8009b 100644 (file)
@@ -41,6 +41,7 @@ foo_SOURCES = foo.c
 END
 
 cat > foo.c << 'END'
+#include <stdio.h>
 #include "h.h"
 int main (void) { printf ("%s\n", F); return 0; }
 END
index 4668e97c7fd27a38feb576b256b40d99d75a5047..a966b4b070269a851d40bc6447a6b5ae555fc24b 100644 (file)
@@ -60,6 +60,7 @@ cat > lexer.l << 'END'
 END
 
 cat > main.c << 'END'
+extern int yylex (void);
 int main (void)
 {
   return yylex ();
index 6486a012f822788aa547407b773fa2f29cfa057f..32dd854b69d8b0debd2dda861f86bf82686fa5e7 100644 (file)
@@ -58,6 +58,10 @@ cat > main.c << 'END'
 #include <stdlib.h>
 #include <string.h>
 
+extern int yylex (void);
+extern int foolex (void);
+extern int bar_lex (void);
+
 int main (int argc, char *argv[])
 {
   if (argc != 2)
index d499aea7f332b127319463a6c6e1e0e879450759..29f0cb0ec58e6ae7b649ce592ddbc6be6f149104 100644 (file)
@@ -61,6 +61,8 @@ CLEANFILES = $(nodist_prog_SOURCES)
 END
 
 cat > main.c << 'END'
+extern int yylex (void);
+
 int main ()
 {
   return yylex ();
index 000d0ad3499c9b90d29e03edd54f5584f85f16ec..c9f7af1dc2d46662c57ed75856705578b084b74c 100644 (file)
@@ -73,6 +73,8 @@ void print (void)
 END
 
 cat > main.c <<'END'
+extern void print(void);
+
 int main (void)
 {
   print();
index 64e42949ad60bdcbbc1807859d1ef8c56834dfa3..3c35f50e706df5d883c5be0de9be5add75246bc8 100644 (file)
@@ -91,6 +91,12 @@ echo 'int sub22 () { return 22; }' > sub2/sub22/sub22.c
 
 cat >test.c <<'EOF'
 #include <stdio.h>
+
+extern int sub1 (void);
+extern int sub2 (void);
+extern int sub21 (void);
+extern int sub22 (void);
+
 int main ()
 {
   if (1 != sub1 ())
index 0b4bb10a7b9325360cc9c30dba5383fcd07abc2b..94af0778b906cdba48a0da8d8d9ce3e4a1801a0f 100644 (file)
@@ -83,7 +83,15 @@ libfoo_la_SOURCES = \
 END
 
 mkdir sub1 sub2
-echo 'int libmain (void)' > main.c
+
+echo "/* Subobj clean: libtool case*/" > main.c
+for i in 1 2; do
+  for j in a b c d e f; do
+    echo "extern void $j$i (void);" >> main.c
+  done
+done
+
+echo 'int libmain (void)' >> main.c
 echo '{' >> main.c
 for i in 1 2; do
   for j in a b c d e f; do
index 591684bc87d045642e15b26812e15ab5cff77cb2..360716ec36f292f30c62fcd103cad013688fd24d 100644 (file)
@@ -81,7 +81,15 @@ foo_SOURCES = \
 END
 
 mkdir sub1 sub2
-echo 'int main (void)' > main.c
+
+echo "/* Subobj clean: generic case*/" > main.c
+for i in 1 2; do
+  for j in a b c d e f; do
+    echo "extern void $j$i (void);" >> main.c
+  done
+done
+
+echo 'int main (void)' >> main.c
 echo '{' >> main.c
 for i in 1 2; do
   for j in a b c d e f; do
index 7e86f7214b0835d60184797cd729903201ba5f19..19ac07da4bab9ce98303a7781a15c1274fad4148 100644 (file)
@@ -53,7 +53,8 @@ noinst_PROGRAMS = zap
 zap_SOURCES = zardoz.pc
 END
 
-echo 'int main(void) [ return bar(1); ]' > foo-main.pc
+echo 'extern int bar(int);' > foo-main.pc
+echo 'int main(void) [ return bar(1); ]' >> foo-main.pc
 echo 'int bar(int x) { return !x; }' > barbar.c
 echo 'int m@in(void) { return 0; }' > sub/zardoz.pc
 
index 51ee5f6a305108d04b00f278d6e57cee86e2cc64..be578e14a722030af6a10f743c57a6d6579f7b1b 100644 (file)
@@ -51,6 +51,7 @@ a : 'a' { exit(0); };
 END
 
 cat > foo.c << 'END'
+extern int yyparse(void);
 int main () { yyparse (); return 1; }
 END
 
index d0f793843ad11b073fb3495c681a49a4e3d2ebf8..da2e3d5b2386247547f7d2935db5f81aad609a05 100644 (file)
@@ -67,6 +67,8 @@ END
 
 cat > sub1/parse.y << 'END'
 %{
+#include <stdio.h>
+
 int yylex () { return (getchar ()); }
 void yyerror (const char *s) {}
 %}
@@ -76,6 +78,8 @@ END
 cp sub1/parse.y sub2/parse.y
 
 cat > sub1/main.c << 'END'
+extern int yyparse(void);
+
 int main ()
 {
   return yyparse ();
index 8e5338e9441f203eb3af042353a92e906c0dfc74..e3b02b3fab5671a8b2fd77f972bf9a48a8d13916 100644 (file)
@@ -80,6 +80,8 @@ BUILT_SOURCES = parse.h
 END
 
 cat > sub1/main.c << 'END'
+extern int yyparse(void);
+
 int main ()
 {
   return yyparse ();