Skip to content

Commit

Permalink
test cases: fix '8 flex' with C23
Browse files Browse the repository at this point in the history
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
  • Loading branch information
thesamesam committed Dec 25, 2024
1 parent 0025805 commit 61eac6a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions test cases/frameworks/8 flex/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#include "parser.tab.h"

extern int yylex(void);
extern int yyerror();
extern int yyerror(char *s);
%}

%option noyywrap nounput noinput

%%
("true"|"false") {return BOOLEAN;}
. { yyerror(); }
. { yyerror("Invalid value"); }
2 changes: 1 addition & 1 deletion test cases/frameworks/8 flex/parser.y
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%{
extern int yylex(void);
extern int yyerror();
extern int yyerror(char *s);
%}

%token BOOLEAN
Expand Down
4 changes: 2 additions & 2 deletions test cases/frameworks/8 flex/prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int yywrap(void) {
return 0;
}

int yyerror(void) {
printf("Parse error\n");
int yyerror(char* s) {
printf("Parse error: %s\n", s);
exit(1);
}

0 comments on commit 61eac6a

Please sign in to comment.