Skip to content

Commit f41e0cf

Browse files
committed
tests: do not depend on config.h
Currently we face test suite failures in different environments, because of a conflict between the definitions of isnan by gnulib, and by the C++ library: 262. headers.at:186: testing Sane headers: %locations %debug c++ ... ./headers.at:186: COLUMNS=1000; export COLUMNS; bison --color=no -fno-caret -d -o input.cc input.y ./headers.at:186: $CXX $CXXFLAGS $CPPFLAGS -c -o input.o input.cc stderr: In file included from /usr/include/c++/4.8.2/cmath:44:0, from /usr/include/c++/4.8.2/random:38, from /usr/include/c++/4.8.2/bits/stl_algo.h:65, from /usr/include/c++/4.8.2/algorithm:62, from location.hh:41, from input.hh:90, from input.cc:50: /u/cs/fac/eggert/src/gnu/bison/lib/math.h: In function 'bool isnan(double)': /u/cs/fac/eggert/src/gnu/bison/lib/math.h:2849:1: error: new declaration 'bool isnan(double)' _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, isnan, bool) ^ In file included from /usr/include/features.h:375:0, from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/os_defines.h:39, from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/c++config.h:2097, from /usr/include/c++/4.8.2/cstdlib:41, from input.hh:48, from input.cc:50: /usr/include/bits/mathcalls.h:235:1: error: ambiguates old declaration 'int isnan(double)' __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); ^ There might be something to do in gnulib about this, but I believe that gnulib should not be used in the test suite in the first place. The test suite should work with other compilers than the one used to compile the package. For a start, Bison sources are more demanding (C99) than the generated parsers. Last time I tried, tcc for example, was not able to compile Bison, yet our generated parsers should compile cleanly with it. Besides the problem at hand is with the C++ compiler, with is not the one used to set up gnulib at configuration-time (config.h is mainly built from probing the C compiler). We should really not depend on gnulib in tests. This was introduced in 2001 to check whether including stdlib.h/string.h is safe thanks to STDC_HEADERS (2ce1014). Today, we assume at least a C90 compiler, it should be safe enough. * tests/local.at, tests/testsuite.h: Do not include config.h. * tests/atlocal.in (conftest.cc): Likewise. (CPPFLAGS): Do not expose lib/, as because of this we might picked up gnulib replacement headers for system headers. * tests/input.at: Use int instead of ptrdiff_t, for easier portability (some machine on the CI did not find ptrdiff_t). * tests/c++.at: Add missing include for getchar.
1 parent d6ce052 commit f41e0cf

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

tests/atlocal.in

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

19-
# We need 'testsuite.h' (srcdir/test), 'config.h' (builddir/lib), and
20-
# the gnulib headers (srcdir/lib).
21-
CPPFLAGS="-I$abs_top_srcdir/tests -I$abs_top_srcdir/lib -I$abs_top_builddir/lib @CPPFLAGS@"
19+
# We need 'testsuite.h' (srcdir/test).
20+
CPPFLAGS="-I$abs_top_srcdir/tests @CPPFLAGS@"
2221

2322
# Don't just check if $POSIXLY_CORRECT is set, as Bash, when launched
2423
# as /bin/sh, sets the shell variable POSIXLY_CORRECT to y, but not
@@ -73,11 +72,7 @@ fi
7372
if $BISON_CXX_WORKS; then
7473
# See AT_DATA_SOURCE_PROLOGUE.
7574
cat >conftest.cc <<EOF
76-
#include <config.h>
77-
/* We don't need perfect functions for these tests. */
78-
#undef malloc
79-
#undef memcmp
80-
#undef realloc
75+
#include <testsuite.h>
8176
#include <iostream>
8277
8378
int main ()

tests/input.at

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ yylex (void)
13221322
*/
13231323
enum { input_elts = sizeof input };
13241324
(void) input_elts;
1325-
static ptrdiff_t toknum;
1325+
static int toknum;
13261326
assert (0 <= toknum && toknum < input_elts);
13271327
yylval = value_as_yystype (input[toknum]);
13281328
return input[toknum++];

tests/local.at

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ m4_define([AT_LANG_DISPATCH],
388388
# The prologue that should be included in any source code that is
389389
# meant to be compiled. Keep atlocal.in sync (BISON_CXX_WORKS).
390390
m4_define([AT_DATA_SOURCE_PROLOGUE],
391-
[[/* Load config.h, and adjust to the compiler.
391+
[[/* Adjust to the compiler.
392392
We used to do it here, but each time we add a new line,
393393
we have to adjust all the line numbers in error messages.
394394
It's simpler to use a constant include to a varying file. */

tests/testsuite.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <config.h>
21
/* We don't need perfect functions for these tests. */
32
#undef malloc
43
#undef memcmp

0 commit comments

Comments
 (0)