From: ian Date: Thu, 10 Feb 2011 23:38:50 +0000 (+0000) Subject: Don't crash on redefined variable. X-Git-Tag: upstream/4.9.2~22864 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc75bc72e268ad530c4a93e029567f7abec3f366;p=platform%2Fupstream%2Flinaro-gcc.git Don't crash on redefined variable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170029 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 53414eb..45ff33d 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -1848,7 +1848,13 @@ Parse::init_var(const Typed_identifier& tid, Type* type, Expression* init, *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