Compare commits

..
29 Commits
Author SHA1 Message Date
Akim Demaille 69b22b49d4 version 3.4.2
* NEWS: Record release date.
2019-09-12 17:41:12 +02:00
Akim Demaille ec11f08fb3 CI: always uninstall icc 2019-09-12 13:16:30 +02:00
Akim Demaille 67444a6f0d news: more bug fixes thanks to Marc Schönefeld 2019-09-12 09:07:48 +02:00
Akim Demaille d120a07e6b diagnostics: beware of unexpected EOF when quoting the source file
When the input file contains lone CRs (aka, ^M, \r), the locations see
a new line.  Diagnostics look only at \n as end-of-line, so sometimes
there is an offset in diagnostics.  Worse yet: sometimes we loop
endlessly waiting for \n to come from a continuous stream of EOF.

Fix that:
- check for EOF
- beware not to call end_use_class if begin_use_class was not
  called (which would abort).  This could happen if the actual
  line is shorter that the expected one.

Prompted by a (private) report from Marc Schönefeld.

* src/location.c (location_caret): here.
* tests/diagnostics.at (Carriage return): New.
2019-09-10 19:15:18 +02:00
Akim Demaille 741a58a504 gnulib: update
Contains the creation of the xhash module.
https://lists.gnu.org/archive/html/bug-gnulib/2019-09/msg00046.html

* src/muscle-tab.c, src/state.c, src/symtab.c, src/uniqstr.c:
Use hash_xinitialize.
2019-09-10 19:06:13 +02:00
Akim Demaille d80815ac23 build: fix distcheck
* configure.ac (gl_LIBOBJS): Adjust so that the generated files are
indeed the expected ones.
2019-09-10 19:06:13 +02:00
Akim Demaille 0b417c3479 tests: add noexcept to please GCC 9
bison/tests/c++.at:552: bison --color=no -fno-caret  -o list.cc list.y
    bison/tests/c++.at:552: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o list list.cc $LIBS
    stderr:
    gcc9/c++/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = string; _Args = {string}; _Tp = string]':
    gcc9/c++/bits/alloc_traits.h:482:2:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = string; _Args = {string}; _Tp = string; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<string>]'
    gcc9/c++/bits/stl_uninitialized.h:888:67:   required from 'void std::__relocate_object_a(_Tp*, _Up*, _Allocator&) [with _Tp = string; _Up = string; _Allocator = std::allocator<string>]'
    gcc9/c++/bits/stl_uninitialized.h:920:47:   required from '_ForwardIterator std::__relocate_a_1(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = string*; _ForwardIterator = string*; _Allocator = std::allocator<string>]'
    gcc9/c++/bits/stl_uninitialized.h:942:37:   required from '_ForwardIterator std::__relocate_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = string*; _ForwardIterator = string*; _Allocator = std::allocator<string>]'
    gcc9/c++/bits/stl_vector.h:430:35:   required from 'static constexpr bool std::vector<_Tp, _Alloc>::_S_nothrow_relocate(std::true_type) [with _Tp = string; _Alloc = std::allocator<string>; std::true_type = std::integral_constant<bool, true>]'
    gcc9/c++/bits/stl_vector.h:446:28:   required from 'void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {const string&}; _Tp = string; _Alloc = std::allocator<string>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<string*, std::vector<string> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = string*]'
    gcc9/c++/bits/stl_vector.h:1195:4:   required from 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = string; _Alloc = std::allocator<string>; std::vector<_Tp, _Alloc>::value_type = string]'
    list.y:126:110:   required from here
    gcc9/c++/bits/vector.tcc:459:44:   in 'constexpr' expansion of 'std::vector<string>::_S_use_relocate()'
    list.y:41:7: error: but 'string::string(string&&)' does not throw; perhaps it should be declared 'noexcept' [-Werror=noexcept]
       41 |       string (string&& s)
          |       ^~~~~~

* tests/c++.at (Variants): Add noexcept where appropriate.
2019-09-08 12:04:36 +02:00
Akim Demaille 77dbdd0d59 news: update 2019-09-08 11:38:29 +02:00
Akim Demaille f8db8fe4d7 fix: don't die when EOF token is defined twice
With

    %token EOF 0 EOF 0

we get

    input.y:3.14-16: warning: symbol EOF redeclared [-Wother]
        3 | %token EOF 0 EOF 0
          |              ^~~
    input.y:3.8-10: previous declaration
        3 | %token EOF 0 EOF 0
          |        ^~~
    Assertion failed: (nsyms == ntokens + nvars), function check_and_convert_grammar,
        file /Users/akim/src/gnu/bison/src/reader.c, line 839.

Reported by Marc Schönefeld.

* src/symtab.c (symbol_user_token_number_set): Register only the
first definition of the end of input token.
* tests/input.at (Symbol redeclared): Check that case.
2019-09-08 11:38:29 +02:00
Akim Demaille 375eb71489 tests: check token redeclaration
* src/symtab.c (symbol_class_set): Report previous definitions when
redeclared.
* tests/input.at (Symbol redeclared): New.
2019-09-08 11:38:29 +02:00
Akim Demaille d3a86f7b20 yacc.c: beware of GCC's -Wmaybe-uninitialized
Test 400 (calc.at:773: testing Calculator api.push-pull=both
api.pure=full parse.error=verbose %debug %locations %defines
api.prefix={calc} %verbose %yacc) fails on the CI with GCC 8 on
Bionic:

    400. calc.at:773: testing Calculator api.push-pull=both api.pure=full parse.error=verbose %debug %locations %defines api.prefix={calc} %verbose %yacc  ...
    ../../tests/calc.at:773: bison --color=no -fno-caret -Wno-deprecated -o calc.c calc.y
    ../../tests/calc.at:773: $CC $CFLAGS $CPPFLAGS  $LDFLAGS -o calc calc.c calc-lex.c calc-main.c $LIBS
    stderr:
    calc.y: In function 'int calcpush_parse(calcpstate*, int, const CALCSTYPE*, CALCLTYPE*)':
    calc.y:26:20: error: 'yylval.CALCSTYPE::ival' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     %printer { fprintf (yyo, "%d", $$); } <ival>;
                        ^
    calc.c:1272:9: note: 'yylval.CALCSTYPE::ival' was declared here
     YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
             ^~~~~~
    cc1plus: all warnings being treated as errors
    stdout:
    ../../tests/calc.at:773: exit code was 1, expected 0
    400. calc.at:773: 400. Calculator api.push-pull=both api.pure=full parse.error=verbose %debug %locations %defines api.prefix={calc} %verbose %yacc  (calc.at:773): FAILED (calc.at:773)

* data/skeletons/c.m4 (yy_symbol_value_print): Disable the warning
locally.
2019-09-08 11:38:29 +02:00
Akim Demaille 29c75ef27f glr.c: initialize vector of bools
The CI, with CC='gcc-7 -fsanitize=undefined,address
-fno-omit-frame-pointer', reports:

    calc.cc:1652:50: runtime error: load of value 190, which is not a valid value for type 'bool'
    ../../tests/calc.at:867: cat stderr
    --- expout	2019-09-05 20:30:37.887257545 +0000
    +++ /home/travis/build/bison-3.4.1.72-79a1-dirty/_build/tests/testsuite.dir/at-groups/438/stdout	2019-09-05 20:30:37.887257545 +0000
    @@ -1 +1,2 @@
     syntax error
    +calc.cc:1652:50: runtime error: load of value 190, which is not a valid value for type 'bool'
    438. calc.at:867: 438. Calculator glr.cc  (calc.at:867): FAILED (calc.at:867)

The problem is that yylookaheadNeeds is not initialized in
yyinitStateSet, and when it is copied, the value is not 0 or 1.

* data/skeletons/glr.c (yylookaheadNeeds): Initialize yylookaheadNeeds.
2019-09-08 11:38:29 +02:00
Akim Demaille 628012d830 gnulib: update
Contains a fix for
https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00016.html.
See
https://lists.gnu.org/archive/html/bug-gnulib/2019-09/msg00005.html.
Reported by 江 祖铭 (Zu-Ming Jiang).
2019-09-08 11:38:29 +02:00
Akim Demaille f788ba2ab6 check for memory exhaustion
hash_initialize returns NULL when out of memory.  Check for it, and
die cleanly instead of crashing.

Reported by 江 祖铭 (Zu-Ming Jiang).
https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00015.html

* src/muscle-tab.c, src/state.c, src/symtab.c, src/uniqstr.c:
Check the value returned by hash_initialize.
2019-09-08 11:38:29 +02:00
László VáradyandAkim Demaille 53526f31df diagnostics: avoid global variables
* src/complain.c (indent_ptr): Remove.
(error_message, complains): Take indent as an argument.
Adjust callers.
2019-09-08 11:38:29 +02:00
László VáradyandAkim Demaille e63811dd86 diagnostics: fix invalid error message indentation
https://lists.gnu.org/archive/html/bison-patches/2019-08/msg00007.html

When Bison is started with a flag that suppresses warning messages, the
error_message() function can produce a few gigabytes of indentation
because of a dangling pointer.

* src/complain.c (error_message): Don't reset indent_ptr here, but...
(complain_indent): here.
* tests/diagnostics.at (Indentation with message suppression): Check
this case.
2019-09-08 11:38:29 +02:00
Akim Demaille 47262c36bb git: ignore files generated in gnulib-po
Because of them, the CI generates "-dirty" tarballs.
2019-09-08 11:38:29 +02:00
Akim Demaille 1e452b1553 c++: avoid duplicate definition of YYUSE
Reported by Frank Heckenbach.
https://lists.gnu.org/archive/html/bug-bison/2019-06/msg00009.html

* data/skeletons/lalr1.cc (b4_shared_declarations): Remove the
duplicate definition of YYUSE, the other one coming from
b4_attribute_define.
2019-09-08 09:59:31 +02:00
Akim Demaille ed796869bb gnulib: update
This update brings file from Gettext 0.20, which is not available on
the CI yet.

.travis.yml: Adjust.
Use Bionic now that it's available.
2019-09-08 09:59:31 +02:00
Akim Demaille 12c412f6bb CI: more compilers
* .travis.yml: Bionic is now available, with GCC8.
GCC7 sanitizers work, but they are too longer: cover only part 1.
Redefine part 1 and part 2 so that part 1 is really the core of the
tests: not playing with POSIX and C++ compiler for C code.
2019-09-08 09:01:18 +02:00
Akim Demaille 2663035ea5 CI: fail fast 2019-09-08 09:01:11 +02:00
Akim Demaille de7c66ab41 CI: propagate sftp failures
* .travis.yml (stage: "compile"): here.
2019-09-08 09:00:58 +02:00
Akim Demaille feeacc2d57 CI: avoid useless git costs
Travis answered favorably to my suggestion to provide a means to
disable git clone on some jobs (issue 7542).  See
https://docs.travis-ci.com/user/customizing-the-build/#disabling-git-clone.

* .travis.yml: Disable git globally, enable it for i. the compile job,
and ii. the test job on ICC which needs the install-icc.sh script.
2019-09-08 09:00:49 +02:00
Akim Demaille cc10f9ab24 CI: factor
* .travis.yml (Clang 7 libc++ and ASAN part 2): Reuse bits from "Clang
7 libc++ and ASAN part 1".
2019-09-08 09:00:30 +02:00
Akim Demaille 1dcd6068dd tests: take SHELL into account
Reported by Dennis Clarke.
http://lists.gnu.org/archive/html/bug-bison/2019-05/msg00053.html

* examples/local.mk, tests/local.mk: here.
2019-05-26 15:29:37 +02:00
Akim Demaille 02f16dc799 gnulib: update to get gnulib translations
This update contains a fix needed for gnulib-po to work properly.
https://lists.gnu.org/archive/html/bug-gnulib/2019-05/msg00146.html
2019-05-26 09:35:31 +02:00
Akim Demaille aa21c457f2 doc: clarify the purpose of symbol_type constructors
Reported by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2019-02/msg00006.html

* doc/bison.texi (Complete Symbols): Here.
2019-05-25 10:28:12 +02:00
Akim Demaille 9f26e6d6b3 thanks: fix an address 2019-05-22 18:09:04 +02:00
Akim Demaille 8d3e782e05 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-05-22 07:45:49 +02:00
27 changed files with 352 additions and 156 deletions
+1 -1
View File
@@ -1 +1 @@
3.4
3.4.1
+82 -58
View File
@@ -20,21 +20,19 @@ stages:
- compile
- test
# The 'test' jobs do not need the repo at all, only the 'compile'
# does. Let's save time, bandwith, energy, and polar bears.
git:
# Manually handle submodules so that we don't have to uselessly waste 150s
# to download gnulib in the 'test' jobs.
submodules: false
# For the same reasons, we would like to not clone the repo either, but it
# does not seem to be possible.
depth: 1
clone: false
# matrix.include and jobs.include are aliases
# (https://docs.travis-ci.com/user/conditional-builds-stages-jobs/).
jobs:
include:
- stage: "compile"
dist: xenial
git:
clone: true
dist: bionic
script:
- sudo apt-get install -qq autoconf automake autopoint flex gettext graphviz help2man m4 texinfo
- autoconf --version
@@ -51,16 +49,23 @@ jobs:
- git submodule update --init --recursive
- ./bootstrap
- ./configure --enable-gcc-warnings CC="$CC" CXX="$CXX" $CONFIGUREFLAGS || { cat config.log && false; }
# gnulib-po/Makefile.in.in is about Gettext 0.20, which is not available in bionic. So it will break here. Override it. Don't use autopoint, which sends some other files in the past.
- cp po/Makefile.in.in gnulib-po
- ./configure --enable-gcc-warnings || { cat config.log && false; }
- make -j2
- make -j2 dist
- dist=$(echo bison*.xz)
# Unfortunately we cannot deterministically know the name of the tarball without the full
# git history (because git describe --abbrev=4 may use more than 4 characters if there are
# conflicts). Besides, one day we would like not to depend on the repository at all in the
# 'test' jobs. So also expose this tarball on a name that only depends on the Travis build
# number.
- sftp [email protected] <<< "put $dist"$'\n'"ln -s $dist bison-$TRAVIS_BUILD_NUMBER.tar.xz"
# conflicts).
#
# So for the sake of the 'test' jobs (that don't even have the repo at all), also expose this
# tarball on a name that only depends on the Travis build number.
#
# Without -b -, exit status is always 0.
- sftp -b - [email protected] <<< "put $dist"$'\n'"ln -s $dist bison-$TRAVIS_BUILD_NUMBER.tar.xz"
## ------- ##
## First. ##
@@ -69,57 +74,52 @@ jobs:
# Start with three completely different environments, to get
# errors asap.
- name: "GCC 7 -O3"
- name: "GCC 8 -O3"
stage: test
os: linux
dist: xenial
dist: bionic
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
- g++-8
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 && CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'"
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8 && CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'"
# ASAN is time consuming, and we timeout the 50min granted by
# Travis if we run all the tests in one go. Run in two parts.
- name: "Clang 7 libc++ and ASAN part 1"
- name: "Clang 8 libc++ and ASAN part 1"
stage: test
os: linux
dist: xenial
addons:
dist: bionic
addons: &clang8
apt:
sources:
- llvm-toolchain-xenial-7
- llvm-toolchain-bionic-8
- ubuntu-toolchain-r-test
packages:
- clang-7
- libc++-7-dev
- libc++abi-7-dev
- clang-8
- libc++-8-dev
- libc++abi-8-dev
env:
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
- MATRIX_EVAL="PART=1 CC='clang-7 -fsanitize=address' CXX='clang++-7 -fsanitize=address -stdlib=libc++'"
- MATRIX_EVAL="PART=1 CC='clang-8 -fsanitize=address' CXX='clang++-8 -fsanitize=address -stdlib=libc++'"
- name: "Clang 7 libc++ and ASAN part 2"
- name: "Clang 8 libc++ and ASAN part 2"
stage: test
os: linux
dist: xenial
addons:
apt:
sources:
- llvm-toolchain-xenial-7
- ubuntu-toolchain-r-test
packages:
- clang-7
- libc++-7-dev
- libc++abi-7-dev
dist: bionic
addons: *clang8
env:
# Do not use ASAN with ubuntu's libc++: https://bugs.llvm.org/show_bug.cgi?id=17379
- MATRIX_EVAL="PART=2 CC='clang-7 -fsanitize=address' CXX='clang++-7 -fsanitize=address -stdlib=libc++'"
- MATRIX_EVAL="PART=2 CC='clang-8 -fsanitize=address' CXX='clang++-8 -fsanitize=address -stdlib=libc++'"
- name: "ICC"
stage: test
# We need the build-aux/install-icc.sh script.
git:
clone: true
submodules: false
depth: 1
os: linux
dist: xenial
env:
@@ -134,23 +134,27 @@ jobs:
## GCC. ##
## ----- ##
#- name: "GCC 8 with sanitizers"
# os: linux
# dist: xenial
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - g++-8
# env:
# # Can't use UBSAN: I get:
# # configure:4951: gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer conftest.c
# # /usr/bin/ld: unrecognized option '--push-state' (on trusty)
# # /usr/bin/ld: unrecognized option '--push-state--no-as-needed' (on xenial)
# #
# # https://stackoverflow.com/questions/50024731/ suggests using the gold linker.
# - MATRIX_EVAL="CC='gcc-8 -fsanitize=undefined,address -fno-omit-frame-pointer' CXX='g++-8 -fsanitize=undefined,address -fno-omit-frame-pointer'"
- name: "GCC 7 with sanitizers"
os: linux
dist: bionic
addons:
apt:
packages:
- g++-7
env:
- MATRIX_EVAL="CC='gcc-7 -fsanitize=undefined,address -fno-omit-frame-pointer' CXX='g++-7 -fsanitize=undefined,address -fno-omit-frame-pointer'"
- PART=1
- name: "GCC 7"
stage: test
os: linux
dist: bionic
addons:
apt:
packages:
- g++-7
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
- name: "GCC 6"
stage: test
@@ -234,6 +238,23 @@ jobs:
## Clang. ##
## ------- ##
- name: "Clang 7 -O3 and libc++"
stage: test
os: linux
dist: bionic
addons:
apt:
sources:
- llvm-toolchain-bionic-7
- ubuntu-toolchain-r-test
packages:
- clang-7
- libc++-7-dev
- libc++abi-7-dev
env:
- MATRIX_EVAL="CC=clang-7 && CXX='clang++-7 -stdlib=libc++'"
- CONFIGUREFLAGS='CPPFLAGS=-DNDEBUG CFLAGS=-O3 CXXFLAGS=-O3'
- name: "Clang 6 -O3 and libc++"
stage: test
os: linux
@@ -413,6 +434,9 @@ script:
# with `Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m`, which makes
# the test suite fail.
- unset _JAVA_OPTIONS
# Fail fast from now on.
- set -e
- sftp [email protected]:bison-$TRAVIS_BUILD_NUMBER.tar.xz
- tar xf bison-$TRAVIS_BUILD_NUMBER.tar.xz
- dir=$(tar tf bison-$TRAVIS_BUILD_NUMBER.tar.xz | sed 1q)
@@ -422,8 +446,8 @@ script:
- ../configure --enable-gcc-warnings CC="$CC" CXX="$CXX" $CONFIGUREFLAGS || { cat config.log && false; }
- make -j2 $MAKE_ARGS
- if test ${PART-1} = 1; then make check VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat test-suite.log && cat tests/testsuite.log && false; }; fi
- if test ${PART-1} = 1; then make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
- if test ${PART-2} = 2; then make maintainer-check-posix VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
- if test ${PART-2} = 2; then make maintainer-check-g++ VERBOSE=1 TESTSUITEFLAGS=-j2 || { cat tests/testsuite.log && false; }; fi
after_script:
- if [[ $CC == "icc" ]]; then uninstall_intel_software; fi
- uninstall_intel_software || true
+17
View File
@@ -1,5 +1,22 @@
GNU Bison NEWS
* Noteworthy changes in release 3.4.2 (2019-09-12) [stable]
** Bug fixes
In some cases, when warnings are disabled, bison could emit tons of white
spaces as diagnostics.
When running out of memory, bison could crash (found by fuzzing).
When defining twice the EOF token, bison would crash.
New warnings from recent compilers have been addressed in the generated
parsers (yacc.c, glr.c, glr.cc).
When lone carriage-return characters appeared in the input file,
diagnostics could hang forever.
* Noteworthy changes in release 3.4.1 (2019-05-22) [stable]
** Bug fixes
+4 -1
View File
@@ -95,10 +95,12 @@ Keith Browne [email protected]
Ken Moffat [email protected]
Kiyoshi Kanazawa [email protected]
Laurent Mascherpa [email protected]
László Várady [email protected]
Lie Yan [email protected]
Magnus Fromreide [email protected]
Marc Autret [email protected]
Marc Mendiola [email protected]
Marc Schönefeld [email protected]
Mark Boyall [email protected]
Martin Jacobs [email protected]
Martin Mokrejs [email protected]
@@ -181,7 +183,7 @@ Tom Tromey [email protected]
Tommy Nordgren [email protected]
Troy A. Johnson [email protected]
Tys Lefering [email protected]
Uxio Prego uxio[email protected]
Uxio Prego uxio@uma.es
Valentin Tolmer [email protected]
wcventure [email protected]
Victor Khomenko [email protected]
@@ -198,6 +200,7 @@ Wwp [email protected]
xolodho [email protected]
Zack Weinberg [email protected]
長田偉伸 [email protected]
江 祖铭 [email protected]
Many people are not named here because we lost track of them. We
thank them! Please, help us keeping this list up to date.
+2 -1
View File
@@ -25,7 +25,7 @@ gnulib_modules='
error extensions fdl fopen-safer
getopt-gnu
gettext-h git-version-gen gitlog-to-changelog
gpl-3.0 hash inttypes isnan javacomp-script
gpl-3.0 inttypes isnan javacomp-script
javaexec-script
ldexpl
libtextstyle-optional
@@ -48,6 +48,7 @@ gnulib_modules='
xalloc
xalloc-die
xconcat-filename
xhash
xlist
xmemdup0
xstrndup
+11
View File
@@ -297,4 +297,15 @@ AC_SUBST([GCC])
AC_CONFIG_FILES([Makefile
po/Makefile.in
doc/yacc.1])
# Fix LIBOBJS to give the Makefile the right file names. Otherwise
# compilation works, but with unexpected file names, so clean rules don't
# remove the actual files and distcheck fails.
AC_CONFIG_COMMANDS_PRE([
case $am__api_version in
1.14*|1.15*) gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/lib_libbison_a-,g'`;;
*) gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/libbison_a-,g'`;;
esac
])
AC_OUTPUT
+2
View File
@@ -545,7 +545,9 @@ m4_if(b4_skeleton, ["yacc.c"],
# endif
]])dnl
b4_percent_code_get([[pre-printer]])dnl
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
b4_symbol_actions([printer])
YY_IGNORE_MAYBE_UNINITIALIZED_END
b4_percent_code_get([[post-printer]])dnl
[}
+6 -3
View File
@@ -1094,17 +1094,20 @@ yyinitStateSet (yyGLRStateSet* yyset)
{
yyset->yysize = 1;
yyset->yycapacity = 16;
yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
yyset->yystates
= (yyGLRState**) YYMALLOC (yyset->yycapacity * sizeof yyset->yystates[0]);
if (! yyset->yystates)
return yyfalse;
yyset->yystates[0] = YY_NULLPTR;
yyset->yylookaheadNeeds =
(yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]);
yyset->yylookaheadNeeds
= (yybool*) YYMALLOC (yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
if (! yyset->yylookaheadNeeds)
{
YYFREE (yyset->yystates);
return yyfalse;
}
memset (yyset->yylookaheadNeeds,
0, yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
return yytrue;
}
-3
View File
@@ -459,9 +459,6 @@ m4_if(b4_prefix, [yy], [],
[#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
]b4_yylloc_default_define])[
// Suppress unused-variable warnings by "using" E.
#define YYUSE(E) ((void) (E))
// Enable debugging if requested.
#if ]b4_api_PREFIX[DEBUG
+13 -7
View File
@@ -11732,15 +11732,21 @@ symbol_type (int token, const int&, const location_type&);
symbol_type (int token, const location_type&);
@end example
@noindent
which should be used in a Flex-scanner as follows.
Correct matching between token types and value types is checked via
@code{assert}; for instance, @samp{symbol_type (ID, 42)} would abort. Named
constructors are preferable (see below), as they offer better type safety
(for instance @samp{make_ID (42)} would not even compile), but symbol_type
constructors may help when token types are discovered at run-time, e.g.,
@example
%%
[a-z]+ return yy::parser::symbol_type (TOK_IDENTIFIER, yytext, loc);
[0-9]+ return yy::parser::symbol_type (TOK_INTEGER, text_to_int (yytext), loc);
":" return yy::parser::symbol_type (':', loc);
<<EOF>> return yy::parser::symbol_type (0, loc);
@group
[a-z]+ @{
if (auto i = lookup_keyword (yytext))
return yy::parser::symbol_type (i, loc);
else
return yy::parser::make_ID (yytext, loc);
@}
@end group
@end example
@sp 1
+1 -1
View File
@@ -33,7 +33,7 @@
## which guarantees that parse.y is indeed shipped.
dist_noinst_SCRIPTS = %D%/extexi %D%/test
TEST_LOG_COMPILER = $(top_srcdir)/%D%/test
TEST_LOG_COMPILER = $(SHELL) $(top_srcdir)/%D%/test
AM_CXXFLAGS = \
$(WARN_CXXFLAGS) $(WARN_CXXFLAGS_TEST) $(WERROR_CXXFLAGS)
+1 -1
Submodule gnulib updated: d654989d8b...672663aca3
+3
View File
@@ -1,9 +1,12 @@
/*.gmo
/*.po
/LINGUAS
/Makefile
/Makefile.in
/Makefile.in.in
/Makevars
/Makevars.template
/POTFILES
/POTFILES.in
/Rules-quot
/bison-gnulib.pot
+1
View File
@@ -321,3 +321,4 @@
/assure.h
/fsync.c
/textstyle.in.h
/xhash.c
+14 -17
View File
@@ -63,8 +63,6 @@ typedef enum
/** For each warning type, its severity. */
static severity warnings_flag[warnings_size];
static unsigned *indent_ptr = NULL;
styled_ostream_t errstream = NULL;
void
@@ -386,6 +384,7 @@ warnings_print_categories (warnings warn_flags, FILE *out)
*
* \param loc the location, defaulting to the current file,
* or the program name.
* \param indent optional indentation for the error message.
* \param flags the category for this message.
* \param sever to decide the prefix to put before the message
* (e.g., "warning").
@@ -397,8 +396,8 @@ warnings_print_categories (warnings warn_flags, FILE *out)
*/
static
void
error_message (const location *loc, warnings flags, severity sever,
const char *message, va_list args)
error_message (const location *loc, unsigned *indent, warnings flags,
severity sever, const char *message, va_list args)
{
unsigned pos = 0;
@@ -408,15 +407,14 @@ error_message (const location *loc, warnings flags, severity sever,
pos += fprintf (stderr, "%s", current_file ? current_file : program_name);
pos += fprintf (stderr, ": ");
if (indent_ptr)
if (indent)
{
if (*indent_ptr)
if (*indent)
sever = severity_disabled;
if (!*indent_ptr)
*indent_ptr = pos;
else if (*indent_ptr > pos)
fprintf (stderr, "%*s", *indent_ptr - pos, "");
indent_ptr = NULL;
if (!*indent)
*indent = pos;
else if (*indent > pos)
fprintf (stderr, "%*s", *indent - pos, "");
}
const char* style = severity_style (sever);
@@ -451,8 +449,8 @@ error_message (const location *loc, warnings flags, severity sever,
/** Raise a complaint (fatal error, error or just warning). */
static void
complains (const location *loc, warnings flags, const char *message,
va_list args)
complains (const location *loc, unsigned *indent, warnings flags,
const char *message, va_list args)
{
severity s = warning_severity (flags);
if ((flags & complaint) && complaint_status < status_complaint)
@@ -462,7 +460,7 @@ complains (const location *loc, warnings flags, const char *message,
{
if (severity_error <= s && ! complaint_status)
complaint_status = status_warning_as_error;
error_message (loc, flags, s, message, args);
error_message (loc, indent, flags, s, message, args);
}
if (flags & fatal)
@@ -474,7 +472,7 @@ complain (location const *loc, warnings flags, const char *message, ...)
{
va_list args;
va_start (args, message);
complains (loc, flags, message, args);
complains (loc, NULL, flags, message, args);
va_end (args);
}
@@ -483,9 +481,8 @@ complain_indent (location const *loc, warnings flags, unsigned *indent,
const char *message, ...)
{
va_list args;
indent_ptr = indent;
va_start (args, message);
complains (loc, flags, message, args);
complains (loc, indent, flags, message, args);
va_end (args);
}
+42 -25
View File
@@ -229,7 +229,13 @@ location_caret (location loc, const char *style, FILE *out)
/* Advance to the line's position, keeping track of the offset. */
while (caret_info.line < loc.start.line)
caret_info.line += getc (caret_info.source) == '\n';
{
int c = getc (caret_info.source);
if (c == EOF)
/* Something is wrong, that line number does not exist. */
return;
caret_info.line += c == '\n';
}
caret_info.offset = ftell (caret_info.source);
/* Read the actual line. Don't update the offset, so that we keep a pointer
@@ -238,32 +244,43 @@ location_caret (location loc, const char *style, FILE *out)
int c = getc (caret_info.source);
if (c != EOF)
{
bool single_line = loc.start.line == loc.end.line;
/* Quote the file (at most the first line in the case of
multiline locations). */
fprintf (out, "%5d | ", loc.start.line);
bool single_line = loc.start.line == loc.end.line;
/* Consider that single point location (with equal boundaries)
actually denote the character that they follow. */
int byte_end = loc.end.byte +
(single_line && loc.start.byte == loc.end.byte);
/* Byte number. */
int byte = 1;
while (c != EOF && c != '\n')
{
if (byte == loc.start.byte)
begin_use_class (style, out);
fputc (c, out);
c = getc (caret_info.source);
++byte;
if (single_line
? byte == byte_end
: c == '\n' || c == EOF)
end_use_class (style, out);
}
putc ('\n', out);
{
/* Print the carets with the same indentation as above. */
fprintf (out, "%5d | ", loc.start.line);
/* Consider that single point location (with equal boundaries)
actually denote the character that they follow. */
int byte_end = loc.end.byte +
(single_line && loc.start.byte == loc.end.byte);
/* Byte number. */
int byte = 1;
/* Whether we opened the style. If the line is not as
expected (maybe the file was changed since the scanner
ran), we might reach the end before we actually saw the
opening column. */
bool opened = false;
while (c != EOF && c != '\n')
{
if (byte == loc.start.byte)
{
begin_use_class (style, out);
opened = true;
}
fputc (c, out);
c = getc (caret_info.source);
++byte;
if (opened
&& (single_line
? byte == byte_end
: c == '\n' || c == EOF))
end_use_class (style, out);
}
putc ('\n', out);
}
/* Print the carets with the same indentation as above. */
{
fprintf (out, " | %*s", loc.start.column - 1, "");
begin_use_class (style, out);
putc ('^', out);
@@ -275,8 +292,8 @@ location_caret (location loc, const char *style, FILE *out)
for (int i = loc.start.column + 1; i < len; ++i)
putc ('~', out);
end_use_class (style, out);
putc ('\n', out);
}
putc ('\n', out);
}
}
}
+2 -2
View File
@@ -126,8 +126,8 @@ muscle_init (void)
/* Initialize the muscle obstack. */
obstack_init (&muscle_obstack);
muscle_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
hash_compare_muscles, muscle_entry_free);
muscle_table = hash_xinitialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
hash_compare_muscles, muscle_entry_free);
/* Version and input file. */
MUSCLE_INSERT_STRING ("version", VERSION);
+4 -2
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.4. */
/* A Bison parser, made by GNU Bison 3.4.1.26-d17af. */
/* Bison implementation for Yacc-like parsers in C
@@ -48,7 +48,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "3.4"
#define YYBISON_VERSION "3.4.1.26-d17af"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -886,6 +886,7 @@ yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YY
/* "%code pre-printer" blocks. */
tron (yyo);
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
switch (yytype)
{
case 3: /* "string" */
@@ -1069,6 +1070,7 @@ tron (yyo);
default:
break;
}
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* "%code post-printer" blocks. */
troff (yyo);
+1 -1
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.4. */
/* A Bison parser, made by GNU Bison 3.4.1.26-d17af. */
/* Bison interface for Yacc-like parsers in C
+5 -5
View File
@@ -359,11 +359,11 @@ state_hasher (void const *s, size_t tablesize)
void
state_hash_new (void)
{
state_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
state_hasher,
state_comparator,
NULL);
state_table = hash_xinitialize (HT_INITIAL_CAPACITY,
NULL,
state_hasher,
state_comparator,
NULL);
}
+18 -12
View File
@@ -462,7 +462,13 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
if (declaring)
{
if (s->status == declared)
complain (&loc, Wother, _("symbol %s redeclared"), sym->tag);
{
unsigned i = 0;
complain (&loc, Wother, _("symbol %s redeclared"), sym->tag);
i += SUB_INDENT;
complain_indent (&sym->location, Wother, &i,
_("previous declaration"));
}
else
s->status = declared;
}
@@ -489,7 +495,7 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
{
*user_token_numberp = user_token_number;
/* User defined $end token? */
if (user_token_number == 0)
if (user_token_number == 0 && !endtoken)
{
endtoken = sym->content->symbol;
/* It is always mapped to 0, so it was already counted in
@@ -773,16 +779,16 @@ hash_semantic_type_hasher (void const *m, size_t tablesize)
void
symbols_new (void)
{
symbol_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
hash_symbol_hasher,
hash_symbol_comparator,
symbol_free);
semantic_type_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
hash_semantic_type_hasher,
hash_semantic_type_comparator,
free);
symbol_table = hash_xinitialize (HT_INITIAL_CAPACITY,
NULL,
hash_symbol_hasher,
hash_symbol_comparator,
symbol_free);
semantic_type_table = hash_xinitialize (HT_INITIAL_CAPACITY,
NULL,
hash_semantic_type_hasher,
hash_semantic_type_comparator,
free);
}
+5 -5
View File
@@ -157,11 +157,11 @@ hash_uniqstr (void const *m, size_t tablesize)
void
uniqstrs_new (void)
{
uniqstrs_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
hash_uniqstr,
hash_compare_uniqstr,
free);
uniqstrs_table = hash_xinitialize (HT_INITIAL_CAPACITY,
NULL,
hash_uniqstr,
hash_compare_uniqstr,
free);
}
+1 -1
View File
@@ -313,7 +313,7 @@ AT_DATA_GRAMMAR([list.y],
}
#if defined __cplusplus && 201103L <= __cplusplus
string (string&& s)
string (string&& s) noexcept
: val_(std::move(s.val_))
{
s.val_.clear();
+73 -4
View File
@@ -35,17 +35,23 @@ AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([[input.y]], [$2])
AT_DATA([experr.orig], [$4])
# For some reason, literal ^M in the input are removed and don't end
# in `input.y`. So use the two-character ^M represent it, and let
# Perl insert real CR characters.
AT_CHECK([perl -pi -e 's{\^M}{\r}gx' input.y])
AT_DATA([experr], [$4])
AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret --color=debug -Wall input.y], [$3], [], [experr])
# When no style, same messages, but without style.
AT_CHECK([perl -p -e 's{</?\w+>}{}g' <experr.orig >experr])
AT_CHECK([perl -pi -e 's{(</?\w+>)}{ $[]1 eq "<tag>" ? $[]1 : "" }ge' experr])
# Cannot use AT_BISON_CHECK easily as we need to change the
# environment.
# FIXME: Enhance AT_BISON_CHECK.
AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret -Wall input.y], [$3], [], [experr])
AT_CHECK([cp experr.orig experr])
AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret --color=debug -Wall input.y], [$3], [], [experr])
AT_BISON_OPTION_POPDEFS
@@ -67,18 +73,33 @@ exp: %empty;
[[input.y:9.12-14: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
9 | %token FOO <warning>FOO</warning> FOO
| <warning>^~~</warning>
input.y:9.8-10: previous declaration
9 | %token <note>FOO</note> FOO FOO
| <note>^~~</note>
input.y:9.16-18: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
9 | %token FOO FOO <warning>FOO</warning>
| <warning>^~~</warning>
input.y:9.8-10: previous declaration
9 | %token <note>FOO</note> FOO FOO
| <note>^~~</note>
input.y:10.8-10: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
10 | %token <warning>FOO</warning> FOO FOO
| <warning>^~~</warning>
input.y:9.8-10: previous declaration
9 | %token <note>FOO</note> FOO FOO
| <note>^~~</note>
input.y:10.13-15: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
10 | %token FOO <warning>FOO</warning> FOO
| <warning>^~~</warning>
input.y:9.8-10: previous declaration
9 | %token <note>FOO</note> FOO FOO
| <note>^~~</note>
input.y:10.18-20: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
10 | %token FOO FOO <warning>FOO</warning>
| <warning>^~~</warning>
input.y:9.8-10: previous declaration
9 | %token <note>FOO</note> FOO FOO
| <note>^~~</note>
]])
@@ -240,5 +261,53 @@ input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option
]])
## ----------------- ##
## Carriage return. ##
## ----------------- ##
# Carriage-return used to count as a newline in the scanner, and not
# in diagnostics. Resulting in all sort of nice bugs.
AT_TEST([[Carriage return]],
[[^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M
%token "
%%
]],
[1],
[[input.y:37.8-38.0: <error>error:</error> missing '"' at end of line
input.y:37.8-38.0: <error>error:</error> syntax error, unexpected string, expecting char or identifier or <tag>
]])
m4_popdef([AT_TEST])
## -------------------------------------- ##
## Indentation with message suppression. ##
## -------------------------------------- ##
AT_SETUP([[Indentation with message suppression]])
# https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00002.html
AT_DATA([[input.y]],
[[%define api.pure
%pure-parser
%error-verbose
%%
exp : '0'
]])
AT_BISON_CHECK([[-fcaret -Wno-other input.y]], [0], [],
[[input.y:2.1-12: warning: deprecated directive, use '%define api.pure' [-Wdeprecated]
2 | %pure-parser
| ^~~~~~~~~~~~
input.y:3.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
3 | %error-verbose
| ^~~~~~~~~~~~~~
]])
AT_CLEANUP
+38
View File
@@ -615,6 +615,44 @@ AT_CHECK_UNUSED_VALUES([1], [1])
AT_CLEANUP
## ------------------- ##
## Symbol redeclared. ##
## ------------------- ##
AT_SETUP([Symbol redeclared])
AT_DATA([[input.y]],
[[%token FOO FOO
%token BAR 12 BAR 12
%token EOF 0 EOF 0
%%
exp: FOO BAR
]])
AT_BISON_CHECK([-fcaret input.y], [0], [],
[[input.y:1.12-14: warning: symbol FOO redeclared [-Wother]
1 | %token FOO FOO
| ^~~
input.y:1.8-10: previous declaration
1 | %token FOO FOO
| ^~~
input.y:2.15-17: warning: symbol BAR redeclared [-Wother]
2 | %token BAR 12 BAR 12
| ^~~
input.y:2.8-10: previous declaration
2 | %token BAR 12 BAR 12
| ^~~
input.y:3.14-16: warning: symbol EOF redeclared [-Wother]
3 | %token EOF 0 EOF 0
| ^~~
input.y:3.8-10: previous declaration
3 | %token EOF 0 EOF 0
| ^~~
]])
AT_CLEANUP
## --------------------------- ##
## Symbol class redefinition. ##
## --------------------------- ##
+1 -1
View File
@@ -85,7 +85,7 @@ $(TESTSUITE): $(TESTSUITE_AT)
## -------------------- ##
# Move into %D%/ so that testsuite.dir etc. be created there.
RUN_TESTSUITE = $(TESTSUITE) -C %D% $(TESTSUITEFLAGS)
RUN_TESTSUITE = $(SHELL) $(TESTSUITE) -C %D% $(TESTSUITEFLAGS)
check_SCRIPTS += $(BISON) %D%/atconfig %D%/atlocal
RUN_TESTSUITE_deps = all $(TESTSUITE) $(check_SCRIPTS)
+4 -5
View File
@@ -397,19 +397,18 @@ AT_BISON_OPTION_POPDEFS
# unnecessarily escaped here even though it would need to be if encoded in a
# C-string literal. Also notice that unnecessary escaping, such as "\?", from
# the user specification is eliminated.
AT_BISON_CHECK([-o input.c input.y], [[0]], [[]],
[[input.y:22.8-14: warning: symbol SPECIAL redeclared [-Wother]
input.y:22.16-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string [-Wother]
]])
AT_BISON_CHECK([-fcaret -o input.c input.y], [[0]], [[]],
[[input.y:22.8-14: warning: symbol SPECIAL redeclared [-Wother]
22 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
| ^~~~~~~
input.y:21.8-14: previous declaration
21 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
| ^~~~~~~
input.y:22.16-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string [-Wother]
22 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]])
AT_COMPILE([input])
# Checking the error message here guarantees that yytname, which does contain