diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-15 22:08:44 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-15 22:08:44 +0000 |
commit | 5b26ad55422e05f0a02c80bddab6bc16f91e6345 (patch) | |
tree | 0bcf4943de772b8c4a8ae55e1cdadbb130fc8410 /gcc | |
parent | 354bc607c125d20218b0b7fd12e6903df40e5880 (diff) | |
download | gcc-5b26ad55422e05f0a02c80bddab6bc16f91e6345.zip gcc-5b26ad55422e05f0a02c80bddab6bc16f91e6345.tar.gz gcc-5b26ad55422e05f0a02c80bddab6bc16f91e6345.tar.bz2 |
Permit _ as a result variable name.
From-SVN: r167877
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/gogo.cc | 19 | ||||
-rw-r--r-- | gcc/go/gofrontend/gogo.h | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index 3a76adb..39072e0 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -640,7 +640,7 @@ Gogo::start_function(const std::string& name, Function_type* type, } } - function->create_named_result_variables(); + function->create_named_result_variables(this); const std::string* pname; std::string nested_name; @@ -2473,7 +2473,7 @@ Function::Function(Function_type* type, Function* enclosing, Block* block, // Create the named result variables. void -Function::create_named_result_variables() +Function::create_named_result_variables(Gogo* gogo) { const Typed_identifier_list* results = this->type_->results(); if (results == NULL @@ -2490,10 +2490,17 @@ Function::create_named_result_variables() p != results->end(); ++p, ++index) { - Result_variable* result = new Result_variable(p->type(), this, - index); - Named_object* no = block->bindings()->add_result_variable(p->name(), - result); + std::string name = p->name(); + if (Gogo::is_sink_name(name)) + { + static int unnamed_result_counter; + char buf[100]; + snprintf(buf, sizeof buf, "_$%d", unnamed_result_counter); + ++unnamed_result_counter; + name = gogo->pack_hidden_name(buf, false); + } + Result_variable* result = new Result_variable(p->type(), this, index); + Named_object* no = block->bindings()->add_result_variable(name, result); this->named_results_->push_back(no); } } diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h index d0cfa1e..49f1be5 100644 --- a/gcc/go/gofrontend/gogo.h +++ b/gcc/go/gofrontend/gogo.h @@ -785,7 +785,7 @@ class Function // Create the named result variables in the outer block. void - create_named_result_variables(); + create_named_result_variables(Gogo*); // Add a new field to the closure variable. void |