fix case/default labels with statement, add a dump commandline flag
authorMatthias Braun <matze@braunis.de>
Wed, 21 Nov 2007 17:39:49 +0000 (17:39 +0000)
committerMatthias Braun <matze@braunis.de>
Wed, 21 Nov 2007 17:39:49 +0000 (17:39 +0000)
[r18511]

ast.c
ast2firm.c
ast_t.h
main.c
parser.c

diff --git a/ast.c b/ast.c
index 27105f6..341d5f2 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -380,6 +380,7 @@ static void print_case_label(const case_label_statement_t *statement)
                print_expression(statement->expression);
                fputs(":\n", out);
        }
+       print_statement(statement->label_statement);
 }
 
 static void print_declaration_statement(
index ec01a7a..7e3216d 100644 (file)
@@ -2258,6 +2258,8 @@ static void case_label_to_firm(const case_label_statement_t *statement)
        }
        add_immBlock_pred(block, proj);
        mature_immBlock(block);
+
+       statement_to_firm(statement->label_statement);
 }
 
 static ir_node *get_label_block(declaration_t *label)
diff --git a/ast_t.h b/ast_t.h
index b965ff6..40a5284 100644 (file)
--- a/ast_t.h
+++ b/ast_t.h
@@ -325,6 +325,7 @@ struct goto_statement_t {
 struct case_label_statement_t {
        statement_t   statement;
        expression_t *expression;
+       statement_t  *label_statement;
 };
 
 struct label_statement_t {
diff --git a/main.c b/main.c
index 4930eaf..299be22 100644 (file)
--- a/main.c
+++ b/main.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <string.h>
 #include <assert.h>
@@ -36,7 +37,8 @@
 #define pclose(file)      _pclose(file)
 #endif /* _WIN32 */
 
-static int verbose;
+static int  verbose;
+static bool do_dump;
 
 static const ir_settings_if_conv_t *if_conv_info = NULL;
 static const backend_params        *be_params    = NULL;
@@ -88,12 +90,9 @@ static void initialize_firm(void)
 
 static void dump(ir_graph *irg, const char *suffix)
 {
-#if 0
-       dump_ir_block_graph(irg, suffix);
-#else
-       (void)irg;
-       (void)suffix;
-#endif
+       if(do_dump) {
+               dump_ir_block_graph(irg, suffix);
+       }
 }
 
 static void get_output_name(char *buf, size_t buflen, const char *inputname,
@@ -324,6 +323,8 @@ int main(int argc, char **argv)
                        mode = PrintAst;
                } else if(strcmp(arg, "--print-fluffy") == 0) {
                        mode = PrintFluffy;
+               } else if(strcmp(arg, "--dump") == 0) {
+                       do_dump = true;
                } else if(strcmp(arg, "-v") == 0) {
                        verbose = 1;
                } else if(arg[0] == '-' && arg[1] == 'f') {
index 3233d05..4af5907 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -3778,7 +3778,7 @@ static statement_t *parse_case_statement(void)
        label->expression = parse_expression();
 
        expect(':');
-       label->statement.next = parse_statement();
+       label->label_statement = parse_statement();
 
        return (statement_t*) label;
 }
@@ -3792,7 +3792,7 @@ static statement_t *parse_default_statement(void)
        label->statement.source_position = token.source_position;
 
        expect(':');
-       label->statement.next = parse_statement();
+       label->label_statement = parse_statement();
 
        return (statement_t*) label;
 }