rename STATEMENT_INVALID to STATEMENT_ERROR
authorMatthias Braun <matze@braunis.de>
Sat, 13 Aug 2011 11:52:58 +0000 (13:52 +0200)
committerMatthias Braun <matze@braunis.de>
Sat, 13 Aug 2011 11:52:58 +0000 (13:52 +0200)
ast.c
ast2firm.c
ast_t.h
parser.c
walk.c

diff --git a/ast.c b/ast.c
index 3b88da7..d421dcf 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1180,8 +1180,8 @@ void print_statement(const statement_t *statement)
        case STATEMENT_LEAVE:
                print_leave_statement(&statement->leave);
                break;
-       case STATEMENT_INVALID:
-               print_string("$invalid statement$\n");
+       case STATEMENT_ERROR:
+               print_string("$error statement$\n");
                break;
        }
 }
index 84c29da..65794f5 100644 (file)
@@ -5494,8 +5494,8 @@ static void statement_to_firm(statement_t *statement)
 #endif
 
        switch (statement->kind) {
-       case STATEMENT_INVALID:
-               panic("invalid statement found");
+       case STATEMENT_ERROR:
+               panic("error statement found");
        case STATEMENT_EMPTY:
                /* nothing */
                return;
diff --git a/ast_t.h b/ast_t.h
index 4ed8563..41367a9 100644 (file)
--- a/ast_t.h
+++ b/ast_t.h
@@ -479,7 +479,7 @@ union initializer_t {
  * The statement kinds.
  */
 typedef enum statement_kind_t {
-       STATEMENT_INVALID,
+       STATEMENT_ERROR = 1,
        STATEMENT_EMPTY,
        STATEMENT_COMPOUND,
        STATEMENT_RETURN,
@@ -514,14 +514,6 @@ struct statement_base_t {
 #endif
 };
 
-struct invalid_statement_t {
-       statement_base_t  base;
-};
-
-struct empty_statement_t {
-       statement_base_t  base;
-};
-
 struct return_statement_t {
        statement_base_t  base;
        expression_t     *value;    /**< The return value if any. */
@@ -667,11 +659,6 @@ struct translation_unit_t {
        statement_t *global_asm;
 };
 
-static inline bool is_invalid_statement(statement_t *statement)
-{
-       return statement->base.kind == STATEMENT_INVALID;
-}
-
 /**
  * Allocate an AST node with given size and
  * initialize all fields with zero.
index 2bafb60..66aa333 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -283,8 +283,8 @@ static void semantic_comparison(binary_expression_t *expression);
 static size_t get_statement_struct_size(statement_kind_t kind)
 {
        static const size_t sizes[] = {
-               [STATEMENT_INVALID]     = sizeof(invalid_statement_t),
-               [STATEMENT_EMPTY]       = sizeof(empty_statement_t),
+               [STATEMENT_ERROR]       = sizeof(statement_base_t),
+               [STATEMENT_EMPTY]       = sizeof(statement_base_t),
                [STATEMENT_COMPOUND]    = sizeof(compound_statement_t),
                [STATEMENT_RETURN]      = sizeof(return_statement_t),
                [STATEMENT_DECLARATION] = sizeof(declaration_statement_t),
@@ -407,9 +407,9 @@ static expression_t *create_error_expression(void)
 /**
  * Creates a new invalid statement.
  */
-static statement_t *create_invalid_statement(void)
+static statement_t *create_error_statement(void)
 {
-       return allocate_statement_zero(STATEMENT_INVALID);
+       return allocate_statement_zero(STATEMENT_ERROR);
 }
 
 /**
@@ -4873,7 +4873,7 @@ static void check_reachable(statement_t *const stmt)
        statement_t *last = stmt;
        statement_t *next;
        switch (stmt->kind) {
-               case STATEMENT_INVALID:
+               case STATEMENT_ERROR:
                case STATEMENT_EMPTY:
                case STATEMENT_ASM:
                        next = stmt->base.next;
@@ -5145,7 +5145,7 @@ found_break_parent:
                }
 
                switch (next->kind) {
-                       case STATEMENT_INVALID:
+                       case STATEMENT_ERROR:
                        case STATEMENT_EMPTY:
                        case STATEMENT_DECLARATION:
                        case STATEMENT_EXPRESSION:
@@ -9035,7 +9035,7 @@ end_of_asm:
 
        return statement;
 end_error:
-       return create_invalid_statement();
+       return create_error_statement();
 }
 
 static statement_t *parse_label_inner_statement(statement_t const *const label, char const *const label_kind)
@@ -9044,7 +9044,7 @@ static statement_t *parse_label_inner_statement(statement_t const *const label,
        switch (token.kind) {
                case '}':
                        errorf(&label->base.source_position, "%s at end of compound statement", label_kind);
-                       inner_stmt = create_invalid_statement();
+                       inner_stmt = create_error_statement();
                        break;
 
                case ';':
@@ -9384,7 +9384,7 @@ static statement_t *parse_switch(void)
        return statement;
 end_error:
        POP_PARENT();
-       return create_invalid_statement();
+       return create_error_statement();
 }
 
 static statement_t *parse_loop_body(statement_t *const loop)
@@ -9426,7 +9426,7 @@ static statement_t *parse_while(void)
        return statement;
 end_error:
        POP_PARENT();
-       return create_invalid_statement();
+       return create_error_statement();
 }
 
 /**
@@ -9461,7 +9461,7 @@ static statement_t *parse_do(void)
        return statement;
 end_error:
        POP_PARENT();
-       return create_invalid_statement();
+       return create_error_statement();
 }
 
 /**
@@ -9532,7 +9532,7 @@ end_error2:
        /* fallthrough */
 
 end_error1:
-       return create_invalid_statement();
+       return create_error_statement();
 }
 
 /**
@@ -9572,7 +9572,7 @@ static statement_t *parse_goto(void)
                else
                        parse_error_expected("while parsing goto", T_IDENTIFIER, NULL);
                eat_until_anchor();
-               return create_invalid_statement();
+               return create_error_statement();
        }
 
        /* remember the goto's in a list for later checking */
@@ -9840,11 +9840,11 @@ static statement_t *parse_ms_try_statment(void)
                statement->ms_try.final_statement = parse_compound_statement(false);
        } else {
                parse_error_expected("while parsing __try statement", T___except, T___finally, NULL);
-               return create_invalid_statement();
+               return create_error_statement();
        }
        return statement;
 end_error:
-       return create_invalid_statement();
+       return create_error_statement();
 }
 
 static statement_t *parse_empty_statement(void)
@@ -10027,7 +10027,7 @@ static statement_t *intern_parse_statement(void)
 
        default:
                errorf(HERE, "unexpected token %K while parsing statement", &token);
-               statement = create_invalid_statement();
+               statement = create_error_statement();
                if (!at_anchor())
                        next_token();
                break;
@@ -10170,7 +10170,7 @@ static statement_t *parse_compound_statement(bool inside_expression_statement)
                        break;
                }
                statement_t *sub_statement = intern_parse_statement();
-               if (is_invalid_statement(sub_statement)) {
+               if (sub_statement->kind == STATEMENT_ERROR) {
                        /* an error occurred. if we are at an anchor, return */
                        if (at_anchor())
                                goto end_error;
diff --git a/walk.c b/walk.c
index ae097f1..f7876e0 100644 (file)
--- a/walk.c
+++ b/walk.c
@@ -361,7 +361,7 @@ static void walk_statement(statement_t *const stmt, const walk_env_t *const env)
                walk_statement(stmt->ms_try.final_statement, env);
                return;
 
-       case STATEMENT_INVALID:
+       case STATEMENT_ERROR:
        case STATEMENT_EMPTY:
        case STATEMENT_CONTINUE:
        case STATEMENT_BREAK: