Skip to content

Commit

Permalink
Don't warn about c_functionend not being reachable
Browse files Browse the repository at this point in the history
This is a special node that represents the end of the function so
isn't really unreachable snowball code.
  • Loading branch information
ojwb committed Mar 30, 2024
1 parent 5eda5d4 commit 1413f3b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions compiler/generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,10 @@ static int check_possible_signals(struct generator * g,
if (res >= 0)
res = !res;
if (res == 0 && p->right) {
fprintf(stderr, "%s:%d: warning: 'not' always signals f so following commands are unreachable\n",
g->analyser->tokeniser->file, p->line_number);
if (p->right->type != c_functionend) {
fprintf(stderr, "%s:%d: warning: 'not' always signals f so following commands are unreachable\n",
g->analyser->tokeniser->file, p->line_number);
}
p->right = NULL;
}
return res;
Expand Down Expand Up @@ -567,8 +569,11 @@ static int check_possible_signals(struct generator * g,
// If any clause of the OR always signals t, then the OR
// always signals t.
if (q->right) {
fprintf(stderr, "%s:%d: warning: command always signals t here so rest of 'or' is unreachable\n",
g->analyser->tokeniser->file, q->line_number);
if (q->right->type != c_functionend) {
fprintf(stderr, "%s:%d: warning: command always signals t here so rest of 'or' is unreachable\n",
g->analyser->tokeniser->file,
q->line_number);
}
q->right = NULL;
}
return 1;
Expand All @@ -595,9 +600,11 @@ int check_possible_signals_list(struct generator * g, struct node * p,
if (res == 0) {
// If any command always signals f, then the list always signals f.
if (p->right) {
fprintf(stderr, "%s:%d: warning: command always signals f here so rest of %s is unreachable\n",
g->analyser->tokeniser->file, p->line_number,
(type == c_and ? "'and'" : "command list"));
if (p->right->type != c_functionend) {
fprintf(stderr, "%s:%d: warning: command always signals f here so rest of %s is unreachable\n",
g->analyser->tokeniser->file, p->line_number,
(type == c_and ? "'and'" : "command list"));
}
p->right = NULL;
}
return res;
Expand Down

0 comments on commit 1413f3b

Please sign in to comment.