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 on local vars #77

Merged
merged 2 commits into from
Apr 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/packcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2898,9 +2898,9 @@ static code_reach_t generate_quantifying_code(generate_t *gen, const node_t *exp
indent += 4;
}
stream__write_characters(gen->stream, ' ', indent);
stream__puts(gen->stream, "const size_t p = ctx->cur;\n");
stream__puts(gen->stream, "const size_t p MARK_VAR_AS_USED = ctx->cur;\n");
stream__write_characters(gen->stream, ' ', indent);
stream__puts(gen->stream, "const size_t n = chunk->thunks.len;\n");
stream__puts(gen->stream, "const size_t n MARK_VAR_AS_USED = chunk->thunks.len;\n");
{
const int l = ++gen->label;
if (generate_code(gen, expr, l, indent, FALSE) != CODE_REACH__ALWAYS_SUCCEED) {
Expand Down Expand Up @@ -3024,9 +3024,9 @@ static code_reach_t generate_alternative_code(generate_t *gen, const node_array_
indent += 4;
}
stream__write_characters(gen->stream, ' ', indent);
stream__puts(gen->stream, "const size_t p = ctx->cur;\n");
stream__puts(gen->stream, "const size_t p MARK_VAR_AS_USED = ctx->cur;\n");
stream__write_characters(gen->stream, ' ', indent);
stream__puts(gen->stream, "const size_t n = chunk->thunks.len;\n");
stream__puts(gen->stream, "const size_t n MARK_VAR_AS_USED = chunk->thunks.len;\n");
for (i = 0; i < nodes->len; i++) {
const bool_t c = (i + 1 < nodes->len) ? TRUE : FALSE;
const int l = ++gen->label;
Expand Down Expand Up @@ -3365,6 +3365,11 @@ static bool_t generate(context_t *ctx) {
"#else\n"
"#define MARK_FUNC_AS_USED __attribute__((__unused__))\n"
"#endif\n"
"#ifdef _MSC_VER\n"
"#define MARK_VAR_AS_USED\n"
"#else\n"
"#define MARK_VAR_AS_USED __attribute__((__unused__))\n"
"#endif\n"
"\n"
"#ifndef PCC_BUFFER_MIN_SIZE\n"
"#define PCC_BUFFER_MIN_SIZE 256\n"
Expand Down
Loading