Skip to content

Commit

Permalink
Merge maint into HEAD
Browse files Browse the repository at this point in the history
* upstream/maint:
  maint: post-release administrivia
  version 3.6.3
  build: check -Wmissing-prototypes
  tests: show logs
  c++: fix printing of state number on streams
  • Loading branch information
akimd committed Jun 3, 2020
2 parents 94f7606 + 508ac09 commit 7e16bd2
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .prev-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.6.2
3.6.3
10 changes: 10 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ GNU Bison NEWS
to the -ffile-prefix-map in GCC. This option can be used to make bison output
reproducible.

* Noteworthy changes in release 3.6.3 (2020-06-03) [stable]

** Bug fixes

Incorrect comments in the generated parsers.

Warnings in push parsers (yacc.c).

Incorrect display of gotos in LAC traces (lalr1.cc).

* Noteworthy changes in release 3.6.2 (2020-05-17) [stable]

** Bug fixes
Expand Down
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ Quoc Peyrot chojin@lrde.epita.fr
R Blake blakers@mac.com
Raja R Harinath harinath@cs.umn.edu
Ralf Wildenhues Ralf.Wildenhues@gmx.de
Ryan dev@splintermail.com
Rich Wilson richaw@gmail.com
Richard Stallman rms@gnu.org
Rici Lake ricilake@gmail.com
Expand Down
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ if test "$enable_gcc_warnings" = yes; then
-Wpointer-arith -Wshadow -Wstrict-aliasing
-Wwrite-strings
-wr188 -wr2259 -wr3179'
warn_c='-Wbad-function-cast -Wstrict-prototypes'
warn_c='-Wbad-function-cast
-Wmissing-prototypes
-Wstrict-prototypes'
warn_cxx='-Wextra-semi -Wnoexcept -Wold-style-cast -Wundefined-func-template
-Wweak-vtables'
# Warnings for the test suite only.
Expand Down
2 changes: 1 addition & 1 deletion data/skeletons/yacc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ yypull_parse (yypstate *yyps]b4_user_formals[)
]b4_parse_state_variable_macros([b4_pstate_macro_define])[

/* Initialize the parser data structure. */
void
static void
yypstate_clear (yypstate *yyps)
{
]b4_initialize_parser_state_variables[
Expand Down
15 changes: 9 additions & 6 deletions doc/bison.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,7 @@ Here is the code for the lexical analyzer:
and tabs, and returns 0 for end-of-input. */

#include <ctype.h>
#include <stdlib.h>
@end group

@group
Expand All @@ -1895,7 +1896,8 @@ yylex (void)
if (c == '.' || isdigit (c))
@{
ungetc (c, stdin);
scanf ("%lf", &yylval);
if (scanf ("%lf", &yylval) != 1)
abort ();
return NUM;
@}
@end group
Expand Down Expand Up @@ -2729,8 +2731,8 @@ yylex (void)
if (c == '.' || isdigit (c))
@{
ungetc (c, stdin);
int n = scanf ("%lf", &yylval.NUM);
assert (n == 1);
if (scanf ("%lf", &yylval.NUM) != 1)
abort ();
return NUM;
@}
@end group
Expand All @@ -2757,10 +2759,10 @@ Bison generated a definition of @code{YYSTYPE} with a member named
if (bufsize <= i)
@{
bufsize = 2 * bufsize + 40;
symbuf = realloc (symbuf, bufsize);
symbuf = realloc (symbuf, (size_t) bufsize);
@}
/* Add this character to the buffer. */
symbuf[i++] = c;
symbuf[i++] = (char) c;
/* Get another character. */
c = getchar ();
@}
Expand Down Expand Up @@ -10630,7 +10632,7 @@ when there were errors. No file was generated (except the reports generated
by @option{--verbose}, etc.). In particular, the output files that possibly
existed were not changed.

@item 63 (mistmatch)
@item 63 (mismatch)
when @command{bison} does not meet the version requirements of the grammar
file. @xref{Require Decl}. No file was generated or changed.
@end table
Expand Down Expand Up @@ -15274,6 +15276,7 @@ London, Department of Computer Science, TR-00-12 (December 2000).
@c LocalWords: YYUNDEF SymbolKind yypcontext YYENOMEM TOKENMAX getBundle
@c LocalWords: ResourceBundle myResources getString getName getToken
@c LocalWords: getLocation getExpectedTokens reportSyntaxError bistromathic
@c LocalWords: TokenKind

@c Local Variables:
@c ispell-dictionary: "american"
Expand Down
1 change: 1 addition & 0 deletions examples/c/bistromathic/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if ENABLE_BISTROMATHIC
-DBISON_LOCALEDIR='"$(localdir)"' \
-DLOCALEDIR='"$(localdir)"' \
-I$(top_srcdir)/%D% -I$(top_builddir)/%D%
%C%_bistromathic_CFLAGS = $(TEST_CFLAGS)
%C%_bistromathic_LDADD = -lm $(LIBREADLINE) $(LIBINTL)
endif

Expand Down
37 changes: 23 additions & 14 deletions examples/c/bistromathic/parse.y
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
%require "3.6"

%code top {
#include <assert.h>
#include <ctype.h> // isdigit
#include <locale.h> // LC_ALL
#include <math.h> // cos, sin, etc.
Expand Down Expand Up @@ -218,7 +217,7 @@ getsym (char const *name)
}

// How many symbols are registered.
int
static int
symbol_count (void)
{
int res = 0;
Expand Down Expand Up @@ -314,7 +313,7 @@ yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc)
`---------*/


const char *
static const char *
error_format_string (int argc)
{
switch (argc)
Expand Down Expand Up @@ -409,7 +408,8 @@ xstrndup (const char *string, size_t n)
const char *end = memchr (string, '\0', n);
size_t len = end ? (size_t) (end - string) : n;
char *new = malloc (len + 1);
assert (new);
if (!new)
abort ();
new[len] = '\0';
return memcpy (new, string, len);
}
Expand All @@ -420,7 +420,8 @@ xstrndup (const char *string, size_t n)
`-----------*/

// Parse (and execute) this line.
int process_line (YYLTYPE *lloc, const char *line)
static int
process_line (YYLTYPE *lloc, const char *line)
{
yypstate *ps = yypstate_new ();
int status = 0;
Expand All @@ -435,7 +436,8 @@ int process_line (YYLTYPE *lloc, const char *line)
}

// Get the list of possible tokens after INPUT was read.
int
// Returns a nonnegative.
static int
expected_tokens (const char *input,
int *tokens, int ntokens)
{
Expand All @@ -456,6 +458,8 @@ expected_tokens (const char *input,

// Then query for the accepted tokens at this point.
int res = yypstate_expected_tokens (ps, tokens, ntokens);
if (res < 0)
abort ();
yypstate_delete (ps);
return res;
}
Expand All @@ -465,7 +469,7 @@ expected_tokens (const char *input,
// TEXT is the word to complete. We can use the entire contents of
// rl_line_buffer in case we want to do some simple parsing. Return
// the array of matches, or NULL if there aren't any.
char **
static char **
completion (const char *text, int start, int end)
{
YYDPRINTF ((stderr, "completion (\"%.*s[%.*s]%s\")\n",
Expand All @@ -475,14 +479,17 @@ completion (const char *text, int start, int end)

// Get list of token numbers.
int tokens[YYNTOKENS];
char *line = xstrndup (rl_line_buffer, start);
char *line = xstrndup (rl_line_buffer, (size_t) start);
int ntokens = expected_tokens (line, tokens, YYNTOKENS);
free (line);

// Build MATCHES, the list of possible completions.
const int len = strlen (text);
const size_t len = strlen (text);
// Need initial prefix and final NULL.
char **matches = calloc (ntokens + symbol_count () + 2, sizeof *matches);
char **matches
= calloc ((size_t) ntokens + (size_t) symbol_count () + 2, sizeof *matches);
if (!matches)
abort ();
int match = 1;
for (int i = 0; i < ntokens; ++i)
switch (tokens[i])
Expand Down Expand Up @@ -512,9 +519,9 @@ completion (const char *text, int start, int end)
matches[0] = strdup (text);
else
{
int lcplen = strlen (matches[1]);
size_t lcplen = strlen (matches[1]);
for (int i = 2; i < match && lcplen; ++i)
for (int j = 0; j < lcplen; ++j)
for (size_t j = 0; j < lcplen; ++j)
if (matches[1][j] != matches[i][j])
lcplen = j;
matches[0] = xstrndup (matches[1], lcplen);
Expand All @@ -538,7 +545,8 @@ completion (const char *text, int start, int end)
return matches;
}

void init_readline (void)
static void
init_readline (void)
{
// Allow conditional parsing of the ~/.inputrc file.
rl_readline_name = "bistromathic";
Expand All @@ -557,7 +565,8 @@ void init_readline (void)
| Main. |
`-------*/

int main (int argc, char const* argv[])
int
main (int argc, char const* argv[])
{
#if defined ENABLE_NLS && ENABLE_NLS
// Set up internationalization.
Expand Down
7 changes: 4 additions & 3 deletions examples/c/calc/calc.y
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
%code top {
#include <assert.h>
#include <ctype.h> /* isdigit. */
#include <stdio.h> /* For printf, etc. */
#include <stdio.h> /* printf. */
#include <stdlib.h> /* abort. */
#include <string.h> /* strcmp. */

int yylex (void);
Expand Down Expand Up @@ -74,8 +75,8 @@ yylex (void)
if (c == '.' || isdigit (c))
{
ungetc (c, stdin);
int n = scanf ("%lf", &yylval.NUM);
assert (n == 1);
if (scanf ("%lf", &yylval.NUM) != 1)
abort ();
return NUM;
}

Expand Down
1 change: 1 addition & 0 deletions examples/c/calc/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ nodist_%C%_calc_SOURCES = %D%/calc.y

# Don't use gnulib's system headers.
%C%_calc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
%C%_calc_CFLAGS = $(TEST_CFLAGS)

dist_calc_DATA = %D%/calc.y %D%/Makefile %D%/README.md
CLEANFILES += %D%/calc.[ch] %D%/calc.output %D%/scan.c
Expand Down
2 changes: 2 additions & 0 deletions examples/c/lexcalc/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ if FLEX_WORKS
nodist_%C%_lexcalc_SOURCES = %D%/parse.y %D%/parse.h %D%/scan.l
# Don't use gnulib's system headers.
%C%_lexcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
# Fighting warnings triggered by Flex is just too painful.
# %C%_lexcalc_CFLAGS = $(TEST_CFLAGS)
endif FLEX_WORKS

%D%/parse.c: $(dependencies)
Expand Down
4 changes: 2 additions & 2 deletions examples/c/lexcalc/scan.l
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
%option nodefault noinput nounput noyywrap

%{
#include <errno.h> /* errno, ERANGE */
#include <errno.h> /* errno, ERANGE */
#include <limits.h> /* INT_MIN */
#include <stdlib.h> /* strtol */

#include "parse.h"

// Each time a rule is matched, advance the end cursor/position.
#define YY_USER_ACTION \
yylloc->last_column += yyleng;
yylloc->last_column += (int) yyleng;

// Move the first position onto the last.
#define LOCATION_STEP() \
Expand Down
1 change: 1 addition & 0 deletions examples/c/mfcalc/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ nodist_%C%_mfcalc_SOURCES = $(mfcalc_sources)
%D%/mfcalc.c: $(dependencies)
# Don't use gnulib's system headers.
%C%_mfcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
%C%_mfcalc_CFLAGS = $(TEST_CFLAGS)
%C%_mfcalc_LDADD = -lm

dist_TESTS += %D%/mfcalc.test
Expand Down
8 changes: 4 additions & 4 deletions examples/c/pushcalc/calc.y
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%code top {
#include <assert.h>
#include <ctype.h> /* isdigit. */
#include <stdio.h> /* For printf, etc. */
#include <stdio.h> /* printf. */
#include <stdlib.h> /* abort. */
#include <string.h> /* strcmp. */
}

Expand Down Expand Up @@ -81,8 +81,8 @@ yylex (YYSTYPE *yylval)
if (c == '.' || isdigit (c))
{
ungetc (c, stdin);
int n = scanf ("%lf", &yylval->NUM);
assert (n == 1);
if (scanf ("%lf", &yylval->NUM) != 1)
abort ();
return NUM;
}

Expand Down
1 change: 1 addition & 0 deletions examples/c/pushcalc/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ nodist_%C%_calc_SOURCES = %D%/calc.y

# Don't use gnulib's system headers.
%C%_calc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
%C%_calc_CFLAGS = $(TEST_CFLAGS)

dist_pushcalc_DATA = %D%/calc.y %D%/Makefile %D%/README.md
CLEANFILES += %D%/calc.[ch] %D%/calc.output
Expand Down
2 changes: 2 additions & 0 deletions examples/c/reccalc/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ if FLEX_WORKS
BUILT_SOURCES += $(nodist_%C%_reccalc_SOURCES)
# Don't use gnulib's system headers.
%C%_reccalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
# Fighting warnings triggered by Flex is just too painful.
# %C%_reccalc_CFLAGS = $(TEST_CFLAGS)
endif FLEX_WORKS

%D%/parse.c: $(dependencies)
Expand Down
4 changes: 2 additions & 2 deletions examples/c/reccalc/scan.l
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
do \
capacity = capacity ? 2 * capacity : 128; \
while (capacity < size + yyleng + 1); \
str = realloc (str, capacity); \
str = realloc (str, (size_t) capacity); \
} \
memcpy (str + size, yytext, yyleng); \
memcpy (str + size, yytext, (size_t) yyleng); \
size += yyleng; \
assert (size < capacity); \
} while (0)
Expand Down
1 change: 1 addition & 0 deletions examples/c/rpcalc/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ nodist_%C%_rpcalc_SOURCES = $(rpcalc_sources)
%D%/rpcalc.c: $(dependencies)
# Don't use gnulib's system headers.
%C%_rpcalc_CPPFLAGS = -I$(top_builddir)/%D%
%C%_rpcalc_CFLAGS = $(TEST_CFLAGS)
%C%_rpcalc_LDADD = -lm

dist_TESTS += %D%/rpcalc.test
Expand Down
3 changes: 3 additions & 0 deletions examples/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
dist_noinst_SCRIPTS = %D%/extexi %D%/test
TEST_LOG_COMPILER = $(SHELL) $(top_srcdir)/%D%/test

TEST_CFLAGS = \
$(WARN_CFLAGS) $(WARN_CFLAGS_TEST) $(WERROR_CFLAGS)

AM_CXXFLAGS = \
$(WARN_CXXFLAGS) $(WARN_CXXFLAGS_TEST) $(WERROR_CXXFLAGS)

Expand Down

0 comments on commit 7e16bd2

Please sign in to comment.