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

Mark unused vars in generated code #75

Closed
wants to merge 4 commits into from

Conversation

masatake
Copy link
Contributor

No description provided.

The parameters are ununused at least calc.c.

Signed-off-by: Masatake YAMATO <[email protected]>
When building Universal Ctags, some local variables in code
generated by packcc cause warnings:

    peg/kotlin.c: In function ‘pcc_evaluate_rule_classParameter’:
    peg/kotlin.c:3474:22: warning: unused variable ‘n’ [-Wunused-variable]
     3474 |         const size_t n = chunk->thunks.len;
	  |                      ^
    peg/kotlin.c:3473:22: warning: unused variable ‘p’ [-Wunused-variable]
     3473 |         const size_t p = ctx->cur;
	  |                      ^

Signed-off-by: Masatake YAMATO <[email protected]>
@arithy
Copy link
Owner

arithy commented Apr 14, 2024

Why do you want to remove the compiler option -Wno-unused-parameter?
I think unused parameters are harmless if they are intendedly left to make functions in the same category have the same signature.

@masatake
Copy link
Contributor Author

Why do you want to remove the compiler option -Wno-unused-parameter?
I think unused parameters are harmless if they are intendedly left to make functions in the same category have the same signature.

As a developer of Universal ctags that uses code generated by packcc, removing unused local variables from the the generated code is enough.

For my purpose, I defined MARKED_VAR_AS_USED. After adding it I found I could use the macro to suppress the warning related to -Wunused-parameter.

I will withdraw this pull request and open a new one specialized in eliminating unused local variables.

@masatake masatake closed this Apr 14, 2024
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

Successfully merging this pull request may close these issues.

2 participants