diff options
author | Linus Torvalds <torvalds@home.transmeta.com> | 2003-05-17 11:32:13 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:00:41 -0700 |
commit | ec69546dc4d1d3fd8853544d0c39af00799dadf3 (patch) | |
tree | 822c80719566e856de0f78e1fd75c1aafd8a4f8a /show-parse.c | |
parent | Add current directory to search path. (diff) | |
download | sparse-ec69546dc4d1d3fd8853544d0c39af00799dadf3.tar.gz sparse-ec69546dc4d1d3fd8853544d0c39af00799dadf3.tar.bz2 sparse-ec69546dc4d1d3fd8853544d0c39af00799dadf3.zip |
Fix switch/case statement show-parse.
Diffstat (limited to 'show-parse.c')
-rw-r--r-- | show-parse.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/show-parse.c b/show-parse.c index f0f54ab..fdceb4b 100644 --- a/show-parse.c +++ b/show-parse.c @@ -344,32 +344,42 @@ static void show_switch_statement(struct statement *stmt) struct symbol *sym; printf("\tswitch v%d\n", val); + /* + * Debugging only: Check that the case list is correct + * by printing it out. + * + * This is where a _real_ back-end would go through the + * cases to decide whether to use a lookup table or a + * series of comparisons etc + */ + printf("case list:\n"); FOR_EACH_PTR(stmt->switch_case->symbol_list, sym) { struct statement *case_stmt = sym->stmt; struct expression *expr = case_stmt->case_expression; struct expression *to = case_stmt->case_to; + printf(" .L%p: ", sym); if (!expr) { - printf("default:\n"); + printf(" default"); } else { if (expr->type == EXPR_VALUE) { - printf("case %lld", expr->value); + printf(" %lld", expr->value); if (to) { if (to->type == EXPR_VALUE) { printf(" .. %lld", to->value); } else { - printf(" .. what"); + printf(" .. what?"); } } - printf(":\n"); } else - printf("case what:\n"); + printf(" what?"); } - show_statement(case_stmt->case_statement); + printf("\n"); } END_FOR_EACH_PTR; if (stmt->switch_break->used) printf(".L%p:\n", stmt->switch_break); + show_statement(stmt->switch_statement); } /* @@ -429,16 +439,7 @@ int show_statement(struct statement *stmt) break; case STMT_CASE: - if (!stmt->case_expression) - printf("default"); - else { - printf("case %lld", stmt->case_expression->value); - if (stmt->case_to) { - printf("...%lld", stmt->case_to->value); - } - - } - printf(":\n"); + printf(".L%p:\n", stmt->case_label); show_statement(stmt->case_statement); break; |