# Macros for the GNU Bison Test suite.
-# Copyright (C) 2003-2011 Free Software Foundation, Inc.
+# Copyright (C) 2003-2012 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
[AT_QUELL_VALGRIND ])[[bison ]]$@)
m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
m4_quote(m4_if(m4_quote($2), [], [0], [$2])), [0], [[
- # POSIXLY_CORRECT=1 causes bison to complain if options are added
- # after the grammar file name, so skip these checks in that case.
- if test x"$POSIXLY_CORRECT" != x1; then
+ # Defining POSIXLY_CORRECT causes bison to complain if options
+ # are added after the grammar file name, so skip these checks
+ # in that case.
+ if test -z "${POSIXLY_CORRECT+set}"; then
# Don't interfere with caller's files.
if test -f stderr; then mv stderr at-bison-check-stderr.bak; fi
if test -f experr; then mv experr at-bison-check-experr.bak; fi
# Build expected stderr up to and including the "warnings being
# treated as errors" message.
]AT_DATA([[at-bison-check-warnings]], [$4])[
- at_bison_check_first="` \
- sed -n '/: warning: /=' at-bison-check-warnings \
- | sed -n 1p \
- `"
- at_bison_check_first_tmp="` \
- sed -n '/conflicts: [0-9].*reduce$/=' at-bison-check-warnings \
- | sed -n 1p \
- `"
+ at_bison_check_first=`sed -n \
+ '/: warning: /{=;q;}' at-bison-check-warnings`
+ : ${at_bison_check_first:=1}
+ at_bison_check_first_tmp=`sed -n \
+ '/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings`
+ : ${at_bison_check_first_tmp:=1}
if test $at_bison_check_first_tmp -lt $at_bison_check_first; then
at_bison_check_first=$at_bison_check_first_tmp
fi
# complaints cause bison to exit early. Thus, with -Werror, bison
# does not necessarily report all warnings that it does without
# -Werror, but it at least reports one.
- at_bison_check_last="`sed -n '$=' stderr`"
- if test x"$at_bison_check_last" = x; then
- at_bison_check_last=1
- fi
- at_bison_check_last="`expr $at_bison_check_last - 1`"
+ at_bison_check_last=`sed -n '$=' stderr`
+ : ${at_bison_check_last:=1}
+ at_bison_check_last=`expr $at_bison_check_last - 1`
sed -n "$at_bison_check_first,$at_bison_check_last"p \
at-bison-check-warnings >> experr
]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \
## Running a generated parser. ##
## ---------------------------- ##
+
# AT_PARSER_CHECK(COMMAND, EXIT-STATUS, EXPOUT, EXPERR, [PRE])
# ------------------------------------------------------------
# So that we can run `./testsuite PREPARSER='valgrind -q' for instance.
+#
+# Get rid of spurious messages when compiled with --coverage:
+# +profiling:/[...]/lib/fprintf.gcda:Merge mismatch for summaries
m4_define([AT_PARSER_CHECK],
-[AT_CHECK([$5 $PREPARSER $1], [$2], [$3], [$4])])
+[AT_CHECK([$5 $PREPARSER $1], [$2], [$3], [stderr])
+AT_CHECK([sed >&2 -e '/^profiling:.*:Merge mismatch for summaries/d' stderr],
+ [0], [], [$4])
+])
+
# AT_JAVA_PARSER_CHECK(COMMAND, EXIT-STATUS, EXPOUT, EXPERR, [PRE])
# -----------------------------------------------------------------
m4_define([AT_JAVA_PARSER_CHECK],
[AT_CHECK([$5[ $SHELL ../../../javaexec.sh ]$1], [$2], [$3], [$4])])
+
# AT_TEST_TABLES_AND_PARSE(TITLE, COND-VALUE, TEST-SPEC,
# DECLS, GRAMMAR, INPUT,
# BISON-STDERR, TABLES-OR-LAST-STATE,
$9
+# Canonical LR generates very large tables, resulting in very long
+# files with #line directives that may overflow what the standards
+# (C90 and C++98) guarantee: 32767. In that case, GCC's -pedantic
+# will issue an error.
+#
+# There is no "" around `wc` since some indent the result.
+m4_bmatch([$4], [%define lr.type canonical-lr],
+[if test 32767 -lt `wc -l < input.c`; then
+ CFLAGS=`echo " $CFLAGS " | sed -e 's/ -pedantic //'`
+ CXXFLAGS=`echo " $CXXFLAGS " | sed -e 's/ -pedantic //'`
+fi])
AT_COMPILE([[input]])
AT_PARSER_CHECK([[./input]],
AT_INIT
+# Cannot assign CC and CFLAGS here, since atlocal is loaded after
+# options are processed, so we don't know the value of CXX and
+# CXXFLAGS yet.
+#
+# Note that it also means that command line values for CXX and
+# CXXFLAGS will not be propagated to CC and CFLAGS.
+AT_ARG_OPTION([compile-c-with-cxx],
+ [compile C parsers with the C++ compiler])
+
+AT_COLOR_TESTS
+
AT_TESTED([bison])