Do not show implicit declarations in --print-ast.
authorChristoph Mallon <christoph.mallon@gmx.de>
Fri, 12 Sep 2008 10:18:53 +0000 (10:18 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Fri, 12 Sep 2008 10:18:53 +0000 (10:18 +0000)
[r21890]

ast.c
ast_t.h
parser.c

diff --git a/ast.c b/ast.c
index 478e642..b970f70 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -963,6 +963,8 @@ static void print_declaration_statement(
             declaration = declaration->next) {
                if (declaration->storage_class == STORAGE_CLASS_ENUM_ENTRY)
                        continue;
+               if (declaration->implicit)
+                       continue;
 
                if (!first) {
                        print_indent();
@@ -1010,10 +1012,13 @@ static void print_do_while_statement(const do_while_statement_t *statement)
 static void print_for_statement(const for_statement_t *statement)
 {
        fputs("for (", out);
-       if(statement->scope.declarations != NULL) {
+       declaration_t *decl = statement->scope.declarations;
+       while (decl != NULL && decl->implicit)
+               decl = decl->next;
+       if (decl != NULL) {
                assert(statement->initialisation == NULL);
-               print_declaration(statement->scope.declarations);
-               if(statement->scope.declarations->next != NULL) {
+               print_declaration(decl);
+               if (decl->next != NULL) {
                        panic("multiple declarations in for statement not supported yet");
                }
                fputc(' ', out);
@@ -1447,6 +1452,8 @@ void print_ast(const translation_unit_t *unit)
                if(declaration->namespc != NAMESPACE_NORMAL &&
                                declaration->symbol == NULL)
                        continue;
+               if (declaration->implicit)
+                       continue;
 
                print_indent();
                print_declaration(declaration);
diff --git a/ast_t.h b/ast_t.h
index 4c4cf92..ac7919b 100644 (file)
--- a/ast_t.h
+++ b/ast_t.h
@@ -551,6 +551,7 @@ struct declaration_t {
        unsigned int        address_taken : 1;
        unsigned int        is_inline     : 1;
        unsigned int        used          : 1;  /**< Set if the declaration is used. */
+       unsigned int        implicit      : 1;
        type_t             *type;
        symbol_t           *symbol;
        source_position_t   source_position;
index f780573..1e305f1 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -5662,6 +5662,7 @@ static declaration_t *create_implicit_function(symbol_t *symbol,
        declaration->type                   = type;
        declaration->symbol                 = symbol;
        declaration->source_position        = *source_position;
+       declaration->implicit               = true;
 
        bool strict_prototypes_old = warning.strict_prototypes;
        warning.strict_prototypes  = false;