This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gccgo] Only warn about no new variables when using :=
- 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, 31 Aug 2010 16:15:41 -0700
- Subject: [gccgo] Only warn about no new variables when using :=
The compiler should only warn about not creating any new variables when
using :=. Otherwise the warning makes no sense. This can happen when
using the special sink variable "_". Committed to gccgo branch.
Ian
diff -r 08d6b67dc3e6 go/parse.cc
--- a/go/parse.cc Tue Aug 31 16:06:34 2010 -0700
+++ b/go/parse.cc Tue Aug 31 16:14:12 2010 -0700
@@ -1543,7 +1543,7 @@
this->init_var(*pv, type, init, is_coloneq, false, &any_new);
}
- if (!any_new)
+ if (is_coloneq && !any_new)
error_at(location, "variables redeclared but no variable is new");
return true;
@@ -1584,7 +1584,7 @@
&any_new);
Expression* present_var = Expression::make_var_reference(no, location);
- if (!any_new)
+ if (is_coloneq && !any_new)
error_at(location, "variables redeclared but no variable is new");
Statement* s = Statement::make_tuple_map_assignment(val_var, present_var,
@@ -1633,7 +1633,7 @@
&any_new);
Expression* received_var = Expression::make_var_reference(no, location);
- if (!any_new)
+ if (is_coloneq && !any_new)
error_at(location, "variables redeclared but no variable is new");
Statement* s = Statement::make_tuple_receive_assignment(val_var,
@@ -1690,7 +1690,7 @@
texpr, t,
location);
- if (!any_new)
+ if (is_coloneq && !any_new)
error_at(location, "variables redeclared but no variable is new");
if (!this->gogo_->in_global_scope())