Skip to content

Commit

Permalink
Fix inlining switch statement.
Browse files Browse the repository at this point in the history
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
sparsecli committed Aug 14, 2011
1 parent 5b57cb8 commit c0719f0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions inline.c
Expand Up @@ -381,6 +381,7 @@ static struct statement *copy_one_statement(struct statement *stmt)
case STMT_CASE: { case STMT_CASE: {
stmt = dup_statement(stmt); stmt = dup_statement(stmt);
stmt->case_label = copy_symbol(stmt->pos, stmt->case_label); 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_expression = copy_expression(stmt->case_expression);
stmt->case_to = copy_expression(stmt->case_to); stmt->case_to = copy_expression(stmt->case_to);
stmt->case_statement = copy_one_statement(stmt->case_statement); stmt->case_statement = copy_one_statement(stmt->case_statement);
Expand Down

0 comments on commit c0719f0

Please sign in to comment.