Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yacc.c raises warnings with -std=c89 -pedantic #109

Open
GitMensch opened this issue Aug 23, 2024 · 0 comments
Open

yacc.c raises warnings with -std=c89 -pedantic #109

GitMensch opened this issue Aug 23, 2024 · 0 comments

Comments

@GitMensch
Copy link

The reason is

bison/data/skeletons/yacc.c

Lines 2008 to 2009 in 25b3d0e

yypcontext_t yyctx
= {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};

which leads to a generation of

        yypcontext_t yyctx
          = {yyssp, yytoken};
        char const *yymsgp = YY_("syntax error");
        int yysyntax_error_status;
        yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);

and therefore raises

parser.c:24521:14: warning: initializer element is not computable at load time [-Wpedantic]
24521 |           = {yyssp, yytoken};
      |              ^~~~~
parser.c:24521:21: warning: initializer element is not computable at load time [-Wpedantic]
24521 |           = {yyssp, yytoken};
      |                     ^~~~~~~

Changing the generated code as follows:

        yypcontext_t yyctx;
        char const *yymsgp = YY_("syntax error");
        int yysyntax_error_status;
        yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
        yyctx.yyssp = yyssp;
        yyctx.yytoken = yytoken;
        yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);

fixes the code, but sadly that is not easily replaced by defining some macros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant