compiler: forbid identifiers named "init" in package scope.
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 26 Jun 2013 15:47:53 +0000 (15:47 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 26 Jun 2013 15:47:53 +0000 (15:47 +0000)
From-SVN: r200426

gcc/go/gofrontend/gogo.cc

index 24f890cdef98529c69c74d2d08d1a058fb75be04..a21493a786c6e7ccab45151eda81a8a8046ddb40 100644 (file)
@@ -1278,6 +1278,14 @@ Gogo::define_global_names()
                   n.c_str());
          inform(pf->second, "%qs imported here", n.c_str());
        }
+
+      // No package scope identifier may be named "init".
+      if (!p->second->is_function()
+         && Gogo::unpack_hidden_name(p->second->name()) == "init")
+       {
+         error_at(p->second->location(),
+                  "cannot declare init - must be func");
+       }
     }
 }