This patch to the Go frontend by Than McIntosh includes global variable preinit blocks in AST dumps. Each preinit block is prefixed with a comment indicating the variable it is initializing. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 261549) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -6743db0ed81e313acf66c00a4ed0e2dcaaca2c9f +1f07926263b6d14edb6abd6a00e6385190d30d0e The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/ast-dump.cc =================================================================== --- gcc/go/gofrontend/ast-dump.cc (revision 261521) +++ gcc/go/gofrontend/ast-dump.cc (working copy) @@ -29,7 +29,7 @@ class Ast_dump_traverse_blocks_and_funct { public: Ast_dump_traverse_blocks_and_functions(Ast_dump_context* ast_dump_context) - : Traverse(traverse_blocks | traverse_functions), + : Traverse(traverse_blocks | traverse_functions | traverse_variables), ast_dump_context_(ast_dump_context) { } @@ -40,6 +40,9 @@ class Ast_dump_traverse_blocks_and_funct int function(Named_object*); + int + variable(Named_object*); + private: Ast_dump_context* ast_dump_context_; }; @@ -150,6 +153,27 @@ Ast_dump_traverse_blocks_and_functions:: return TRAVERSE_CONTINUE; } +// Dump variable preinits + +int +Ast_dump_traverse_blocks_and_functions::variable(Named_object* no) +{ + if (!no->is_variable()) + return TRAVERSE_CONTINUE; + + Variable* var = no->var_value(); + if (var->has_pre_init()) + { + this->ast_dump_context_->ostream() << "// preinit block for var " + << no->message_name() << "\n"; + var->preinit()->traverse(this); + } + + return TRAVERSE_CONTINUE; +} + + + // Class Ast_dump_context. Ast_dump_context::Ast_dump_context(std::ostream* out /* = NULL */,