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.
This commit is contained in:
Alan Modra 2021-11-06 20:48:14 +10:30
parent e8f81980ce
commit 314ec7aeeb
9 changed files with 26 additions and 24 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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')

View File

@ -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;
}

View File

@ -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 : "<unknown-file>", linenumber, err);
return 0;
}