I noticed a new build failure in coreutils when configuring with 
--enable-gcc-warnings.
GCC is 10.2.1.
Fixed with the attached. Tested with the following. Fails before, succeeds 
after:

CFLAGS='-Werror -Wmissing-declarations' ./gnulib-tool --create-testdir --test 
--dir /tmp/x --with-tests verify

Symptoms:
...
gcc -DHAVE_CONFIG_H -I. -I../../gltests  -DGNULIB_STRICT_CHECKING=1 -I. 
-I../../gltests -I.. -I../../gltests/.. -I../gllib \
  -I../../gltests/../gllib   -Werror -Wmissing-declarations -MT test-verify.o 
-MD -MP -MF .deps/test-verify.Tpo -c \
  -o test-verify.o ../../gltests/test-verify.c
../../gltests/test-verify.c:84:1: error: no previous declaration for 
‘test_assume_expressions’ [-Werror=missing-declarations]
   84 | test_assume_expressions (state *s)
      | ^~~~~~~~~~~~~~~~~~~~~~~
../../gltests/test-verify.c:94:1: error: no previous declaration for 
‘test_assume_optimization’ [-Werror=missing-declarations]
   94 | test_assume_optimization (int x)
      | ^~~~~~~~~~~~~~~~~~~~~~~~
../../gltests/test-verify.c:106:1: error: no previous declaration for 
‘test_assume_noreturn’ [-Werror=missing-declarations]
  106 | test_assume_noreturn (void)
      | ^~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Have a nice day,
Berny
>From bc070830dcb1c931472ed38c2b0faa0606a4682d Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Fri, 30 Oct 2020 02:46:44 +0100
Subject: [PATCH] test-verify.c: avoid -Wmissing-declarations warnings

* tests/test-verify.c (test_assume_expressions): Add declaration.
(test_assume_optimization): Likewise.
(test_assume_noreturn): Likewise.
(main): Move down after all other definitions.  While at it, also
call test_assume_expressions and test_assume_optimization as a
runtime check.
---
 ChangeLog           | 10 ++++++++++
 tests/test-verify.c | 20 ++++++++++++++------
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4eb5bcb1d..847b1b62c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-10-30  Bernhard Voelker  <[email protected]>
+
+	test-verify.c: avoid -Wmissing-declarations warnings
+	* tests/test-verify.c (test_assume_expressions): Add declaration.
+	(test_assume_optimization): Likewise.
+	(test_assume_noreturn): Likewise.
+	(main): Move down after all other definitions.  While at it, also
+	call test_assume_expressions and test_assume_optimization as a
+	runtime check.
+
 2020-10-26  Paul Eggert  <[email protected]>
 
 	sys_stat: update comments for S_IRWXUGO, S_IXUGO
diff --git a/tests/test-verify.c b/tests/test-verify.c
index 05e113c0a..1ed78c930 100644
--- a/tests/test-verify.c
+++ b/tests/test-verify.c
@@ -64,12 +64,6 @@ function (int n)
   return 0;
 }
 
-int
-main (void)
-{
-  return !(function (0) == 0 && function (1) == 8);
-}
-
 /* ============================== Test assume ============================== */
 
 static int
@@ -80,6 +74,10 @@ f (int a)
 
 typedef struct { unsigned int context : 4; unsigned int halt : 1; } state;
 
+void test_assume_expressions (state *s);
+int test_assume_optimization (int x);
+void test_assume_noreturn (void);
+
 void
 test_assume_expressions (state *s)
 {
@@ -109,3 +107,13 @@ test_assume_noreturn (void)
      This function should not elicit a warning.  */
   assume (0);
 }
+
+/* ============================== Main ===================================== */
+int
+main (void)
+{
+  state s;
+  test_assume_expressions (&s);
+  test_assume_optimization (5);
+  return !(function (0) == 0 && function (1) == 8);
+}
-- 
2.29.0

Reply via email to