This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Don't crash if tuple init redefines non-variable
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Tue, 04 Jan 2011 13:15:28 -0800
- Subject: Go patch committed: Don't crash if tuple init redefines non-variable
This patch to the Go frontend avoids a crash if a tuple initializer is
used to define a variable, but the definition is erroneous because the
name is already defined as something other than a variable.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.
Ian
diff -r 0087a6ca3b8b go/parse.cc
--- a/go/parse.cc Tue Jan 04 12:17:58 2011 -0800
+++ b/go/parse.cc Tue Jan 04 13:12:50 2011 -0800
@@ -1655,9 +1655,15 @@
if (!this->gogo_->in_global_scope())
this->gogo_->add_statement(s);
else if (!val_no->is_sink())
- val_no->var_value()->add_preinit_statement(s);
+ {
+ if (val_no->is_variable())
+ val_no->var_value()->add_preinit_statement(s);
+ }
else if (!no->is_sink())
- no->var_value()->add_preinit_statement(s);
+ {
+ if (no->is_variable())
+ no->var_value()->add_preinit_statement(s);
+ }
else
{
// Execute the map index expression just so that we can fail if
@@ -1716,9 +1722,15 @@
if (!this->gogo_->in_global_scope())
this->gogo_->add_statement(s);
else if (!val_no->is_sink())
- val_no->var_value()->add_preinit_statement(s);
+ {
+ if (val_no->is_variable())
+ val_no->var_value()->add_preinit_statement(s);
+ }
else if (!no->is_sink())
- no->var_value()->add_preinit_statement(s);
+ {
+ if (no->is_variable())
+ no->var_value()->add_preinit_statement(s);
+ }
else
{
Named_object* dummy = this->create_dummy_global(Type::lookup_bool_type(),
@@ -1776,9 +1788,15 @@
if (!this->gogo_->in_global_scope())
this->gogo_->add_statement(s);
else if (!val_no->is_sink())
- val_no->var_value()->add_preinit_statement(s);
+ {
+ if (val_no->is_variable())
+ val_no->var_value()->add_preinit_statement(s);
+ }
else if (!no->is_sink())
- no->var_value()->add_preinit_statement(s);
+ {
+ if (no->is_variable())
+ no->var_value()->add_preinit_statement(s);
+ }
else
{
Named_object* dummy = this->create_dummy_global(type, NULL, location);