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...
1 parent 5b57cb8 commit c0719f0fbb21d16a786fdf202c7f424e40abf51b @sparsecli sparsecli committed Aug 14, 2011
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.