diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-20 23:29:10 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-20 23:29:10 +0000 |
commit | 435bcccda66129794b2a60c627c83cbe9d0c4de1 (patch) | |
tree | 45ad88a8af609cae499c56deb69918d423c12114 /gcc | |
parent | 82294ec1a9a71e57dc4821649643026d27860701 (diff) | |
download | gcc-435bcccda66129794b2a60c627c83cbe9d0c4de1.zip gcc-435bcccda66129794b2a60c627c83cbe9d0c4de1.tar.gz gcc-435bcccda66129794b2a60c627c83cbe9d0c4de1.tar.bz2 |
compiler: Handle _ with explicit type correctly.
From-SVN: r183358
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 37a9782..49e42de 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -1883,10 +1883,23 @@ Parse::init_var(const Typed_identifier& tid, Type* type, Expression* init, { if (!type_from_init && init != NULL) { - if (!this->gogo_->in_global_scope()) + if (this->gogo_->in_global_scope()) + return this->create_dummy_global(type, init, location); + else if (type == NULL) this->gogo_->add_statement(Statement::make_statement(init, true)); else - return this->create_dummy_global(type, init, location); + { + // With both a type and an initializer, create a dummy + // variable so that we will check whether the + // initializer can be assigned to the type. + Variable* var = new Variable(type, init, false, false, false, + location); + static int count; + char buf[30]; + snprintf(buf, sizeof buf, "sink$%d", count); + ++count; + return this->gogo_->add_variable(buf, var); + } } return this->gogo_->add_sink(); } |