From: Alan Modra Date: Sat, 6 Nov 2021 10:18:14 +0000 (+1030) Subject: Modernise yyerror X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=314ec7aeeb1b2e68f0d8fb9990f2335f475a6e33;p=binutils-gdb.git Modernise yyerror Newer versions of bison emit a prototype for yyerror void yyerror (const char *); This clashes with some of our old code that declares yyerror to return an int. Fix that in most cases by modernizing yyerror. bfin-parse.y uses the return value all over the place, so for there disable generation of the prototype as specified by posix. binutils/ * arparse.y (yyerror): Return void. * dlltool.c (yyerror): Likewise. * dlltool.h (yyerror): Likewise. * sysinfo.y (yyerror): Likewise. * windmc.h (yyerror): Likewise. * mclex.c (mc_error): Extract from .. (yyerror): ..here, both now returning void. gas/ * config/bfin-parse.y (yyerror): Define. (yyerror): Make static. * itbl-parse.y (yyerror): Return void. ld/ * deffilep.y (def_error): Return void. --- diff --git a/binutils/arparse.y b/binutils/arparse.y index 5fee56262a1..7ea5e7ff0db 100644 --- a/binutils/arparse.y +++ b/binutils/arparse.y @@ -31,7 +31,7 @@ #include "arsup.h" extern int verbose; extern int yylex (void); -static int yyerror (const char *); +static void yyerror (const char *); %} %union { @@ -193,11 +193,10 @@ verbose_command: %% -static int +static void yyerror (const char *x ATTRIBUTE_UNUSED) { extern int linenumber; printf (_("Syntax error in archive script, line %d\n"), linenumber + 1); - return 0; } diff --git a/binutils/dlltool.c b/binutils/dlltool.c index e6fafb4dc84..4f337f78d24 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -990,13 +990,11 @@ static int d_nforwards = 0; /* Number of forwarded exports. */ static int d_is_dll; static int d_is_exe; -int +void yyerror (const char * err ATTRIBUTE_UNUSED) { /* xgettext:c-format */ non_fatal (_("Syntax error in def file %s:%d"), def_file, linenumber); - - return 0; } void diff --git a/binutils/dlltool.h b/binutils/dlltool.h index 72d05378022..74e9b817161 100644 --- a/binutils/dlltool.h +++ b/binutils/dlltool.h @@ -31,7 +31,7 @@ extern void def_section (const char *, int); extern void def_stacksize (int, int); extern void def_version (int, int); extern int yyparse (void); -extern int yyerror (const char *); +extern void yyerror (const char *); extern int yylex (void); extern int yydebug; diff --git a/binutils/mclex.c b/binutils/mclex.c index aa1814cc745..670e88652e9 100644 --- a/binutils/mclex.c +++ b/binutils/mclex.c @@ -103,14 +103,19 @@ mc_fatal (const char *s, ...) } -int -yyerror (const char *s, ...) +static void +mc_error (const char *s, ...) { va_list argp; va_start (argp, s); show_msg ("parser", s, argp); va_end (argp); - return 1; +} + +void +yyerror (const char *s) +{ + mc_error (s); } static unichar * @@ -451,7 +456,7 @@ yylex (void) yylval.ustr = get_diff (input_stream_pos, start_token); return MCIDENT; } - yyerror ("illegal character 0x%x.", ch); + mc_error ("illegal character 0x%x.", ch); } return -1; } diff --git a/binutils/sysinfo.y b/binutils/sysinfo.y index 3d09fc0f958..7aca49ef7f8 100644 --- a/binutils/sysinfo.y +++ b/binutils/sysinfo.y @@ -33,7 +33,7 @@ static int rdepth; static char *names[] = {" ","[n]","[n][m]"}; static char *pnames[]= {"","*","**"}; -static int yyerror (char *s); +static void yyerror (const char *s); extern int yylex (void); %} @@ -434,9 +434,8 @@ if (writecode == 'd') return 0; } -static int -yyerror (char *s) +static void +yyerror (const char *s) { fprintf(stderr, "%s\n" , s); - return 0; } diff --git a/binutils/windmc.h b/binutils/windmc.h index edea8735801..e3ef2e314ce 100644 --- a/binutils/windmc.h +++ b/binutils/windmc.h @@ -80,7 +80,7 @@ mc_node_lang *mc_add_node_lang (mc_node *, const mc_keyword *, rc_uint_type); mc_node *mc_add_node (void); /* Standard yacc/flex stuff. */ -int yyerror (const char *, ...); +void yyerror (const char *); int yylex (void); int yyparse (void); diff --git a/gas/config/bfin-parse.y b/gas/config/bfin-parse.y index 980cf98d57a..5b93d4a6611 100644 --- a/gas/config/bfin-parse.y +++ b/gas/config/bfin-parse.y @@ -25,6 +25,10 @@ #include "elf/common.h" #include "elf/bfin.h" +/* This file uses an old-style yyerror returning int. Disable + generation of a modern prototype for yyerror. */ +#define yyerror yyerror + #define DSP32ALU(aopcde, HL, dst1, dst0, src0, src1, s, x, aop) \ bfin_gen_dsp32alu (HL, aopcde, aop, s, x, dst0, dst1, src0, src1) @@ -160,7 +164,6 @@ static Expr_Node *unary (Expr_Op_Type, Expr_Node *); static void notethat (const char *, ...); extern char *yytext; -int yyerror (const char *); /* Used to set SRCx fields to all 1s as described in the PRM. */ static Register reg7 = {REG_R7, 0}; @@ -177,7 +180,7 @@ void error (const char *format, ...) as_bad ("%s", buffer); } -int +static int yyerror (const char *msg) { if (msg[0] == '\0') diff --git a/gas/itbl-parse.y b/gas/itbl-parse.y index c06b4a803d9..7f56c73cfc4 100644 --- a/gas/itbl-parse.y +++ b/gas/itbl-parse.y @@ -274,7 +274,7 @@ FIXME! hex is ambiguous with any digit static int sbit, ebit; static struct itbl_entry *insn=0; -static int yyerror (const char *); +static void yyerror (const char *); %} @@ -449,9 +449,8 @@ value: ; %% -static int +static void yyerror (const char *msg) { printf ("line %d: %s\n", insntbl_line, msg); - return 0; } diff --git a/ld/deffilep.y b/ld/deffilep.y index e58d0e0bcb5..6bed6437fe2 100644 --- a/ld/deffilep.y +++ b/ld/deffilep.y @@ -102,7 +102,7 @@ static void def_version (int, int); static void def_directive (char *); static void def_aligncomm (char *str, int align); static int def_parse (void); -static int def_error (const char *); +static void def_error (const char *); static int def_lex (void); static int lex_forced_token = 0; @@ -1261,12 +1261,11 @@ def_aligncomm (char *str, int align) } } -static int +static void def_error (const char *err) { einfo ("%P: %s:%d: %s\n", def_filename ? def_filename : "", linenumber, err); - return 0; }