Handle implicit casts from 0 to pointers in comparisons.
[cparser] / ast.c
diff --git a/ast.c b/ast.c
index 8c3c54b..da18516 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -237,6 +237,7 @@ static void print_select(const select_expression_t *expression)
 void print_expression(const expression_t *expression)
 {
        switch(expression->type) {
+       case EXPR_UNKNOWN:
        case EXPR_INVALID:
                fprintf(out, "*invalid expression*");
                break;
@@ -321,17 +322,18 @@ static void print_expression_statement(const expression_statement_t *statement)
 static void print_goto_statement(const goto_statement_t *statement)
 {
        fprintf(out, "goto ");
-       if(statement->label != NULL) {
-               fprintf(out, "%s", statement->label->symbol->string);
-       } else {
-               fprintf(out, "?%s", statement->label_symbol->string);
-       }
+       fputs(statement->label->symbol->string, out);
+       fprintf(stderr, "(%p)", (void*) statement->label);
        fputs(";\n", out);
 }
 
 static void print_label_statement(const label_statement_t *statement)
 {
-       fprintf(out, "%s:\n", statement->symbol->string);
+       fprintf(stderr, "(%p)", (void*) statement->label);
+       fprintf(out, "%s:\n", statement->label->symbol->string);
+       if(statement->label_statement != NULL) {
+               print_statement(statement->label_statement);
+       }
 }
 
 static void print_if_statement(const if_statement_t *statement)
@@ -517,9 +519,13 @@ void print_initializer(const initializer_t *initializer)
 
 static void print_normal_declaration(const declaration_t *declaration)
 {
-       print_storage_class(declaration->storage_class);
+       print_storage_class((storage_class_t)declaration->storage_class);
        print_type_ext(declaration->type, declaration->symbol,
                       &declaration->context);
+       if(declaration->is_inline) {
+               fputs("inline ", out);
+       }
+
        if(declaration->type->type == TYPE_FUNCTION) {
                if(declaration->init.statement != NULL) {
                        fputs("\n", out);