aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-02-10 23:38:50 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-02-10 23:38:50 +0000
commitd5f3d14a4282516308125595fcc79d1b6d235f9c (patch)
treed2d355b333e597d396f653d8a6819b80bf8cd269 /gcc
parent8629c99851908ef1b958c35be0fe2b279f1275b3 (diff)
downloadgcc-d5f3d14a4282516308125595fcc79d1b6d235f9c.zip
gcc-d5f3d14a4282516308125595fcc79d1b6d235f9c.tar.gz
gcc-d5f3d14a4282516308125595fcc79d1b6d235f9c.tar.bz2
Don't crash on redefined variable.
From-SVN: r170029
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/parse.cc8
1 files changed, 7 insertions, 1 deletions
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