Skip to content

Commit 61eac6a

Browse files
committed
test cases: fix '8 flex' with C23
With C23 (as upcoming GCC 15 will default to), `void yyerror()` is the same as `void yyerror(void)`, i.e. `yyerror` takes no arguments. Fix the prototype given we *do* call it with an error string: ``` pgen.p/parser.tab.c: In function ‘yyparse’: pgen.p/parser.tab.c:1104:7: error: too many arguments to function ‘yyerror’ 1104 | yyerror (YY_("syntax error")); | ^~~~~~~ ../test cases/frameworks/8 flex/parser.y:3:12: note: declared here 3 | extern int yyerror(); | ^~~~~~~ pgen.p/parser.tab.c:1215:3: error: too many arguments to function ‘yyerror’ 1215 | yyerror (YY_("memory exhausted")); | ^~~~~~~ ../test cases/frameworks/8 flex/parser.y:3:12: note: declared here 3 | extern int yyerror(); | ^~~~~~~ ``` Bug: https://bugs.gentoo.org/946625
1 parent 0025805 commit 61eac6a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

test cases/frameworks/8 flex/lexer.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#include "parser.tab.h"
44

55
extern int yylex(void);
6-
extern int yyerror();
6+
extern int yyerror(char *s);
77
%}
88

99
%option noyywrap nounput noinput
1010

1111
%%
1212
("true"|"false") {return BOOLEAN;}
13-
. { yyerror(); }
13+
. { yyerror("Invalid value"); }

test cases/frameworks/8 flex/parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%{
22
extern int yylex(void);
3-
extern int yyerror();
3+
extern int yyerror(char *s);
44
%}
55

66
%token BOOLEAN

test cases/frameworks/8 flex/prog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int yywrap(void) {
2424
return 0;
2525
}
2626

27-
int yyerror(void) {
28-
printf("Parse error\n");
27+
int yyerror(char* s) {
28+
printf("Parse error: %s\n", s);
2929
exit(1);
3030
}

0 commit comments

Comments
 (0)