Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix inlining switch statement.

In sparse, inline is replacing the function call
expression with a compound statment of inline
function body. During the process, all reference
to the function arguments need to replaced with
calling arguments.

When inlining the case statement. Sparse forgets
to replace the case_label->stmt to the new version.
If it has inner inline function call, it will cause
the orignal copy of the function definition get
modified. That should never happen.

It cause warning error when the inline
function call the second time.

With this change, validations/bug_inline_switch.c
no longer generate warning.

Signed-off-by: Christopher Li <sparse@chrisli.org>
  • Loading branch information...
commit c0719f0fbb21d16a786fdf202c7f424e40abf51b 1 parent 5b57cb8
@sparsecli sparsecli authored
Showing with 1 addition and 0 deletions.
  1. +1 −0  inline.c
View
1  inline.c
@@ -381,6 +381,7 @@ static struct statement *copy_one_statement(struct statement *stmt)
case STMT_CASE: {
stmt = dup_statement(stmt);
stmt->case_label = copy_symbol(stmt->pos, stmt->case_label);
+ stmt->case_label->stmt = stmt;
stmt->case_expression = copy_expression(stmt->case_expression);
stmt->case_to = copy_expression(stmt->case_to);
stmt->case_statement = copy_one_statement(stmt->case_statement);

0 comments on commit c0719f0

Please sign in to comment.
Something went wrong with that request. Please try again.