| Submitter | Ian Taylor |
|---|---|
| Date | Feb. 10, 2011, 11:38 p.m. |
| Message ID | <mcr4o8biho3.fsf@google.com> |
| Download | mbox | patch |
| Permalink | /patch/82693/ |
| State | New |
| Headers | show |
Comments
Patch
diff -r 2ad66018000c go/parse.cc --- a/go/parse.cc Thu Feb 10 15:06:29 2011 -0800 +++ b/go/parse.cc Thu Feb 10 15:33:40 2011 -0800 @@ -1848,7 +1848,13 @@ *is_new = true; Variable* var = new Variable(type, init, this->gogo_->in_global_scope(), false, false, location); - return this->gogo_->add_variable(tid.name(), var); + Named_object* no = this->gogo_->add_variable(tid.name(), var); + if (!no->is_variable()) + { + // The name is already defined, so we just gave an error. + return this->gogo_->add_sink(); + } + return no; } // Create a dummy global variable to force an initializer to be run in