This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: error on func declaration/definition
- From: Ian Lance Taylor <iant at golang dot org>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, gofrontend-dev at googlegroups dot com
- Date: Mon, 12 Feb 2018 11:29:59 -0800
- Subject: Go patch committed: error on func declaration/definition
- Authentication-results: sourceware.org; auth=none
Long long long ago Go permitted writing
func F()
in one file and writing
func F() {}
in another file. This was removed from the language, and that is now
considered to be a multiple definition error. Gccgo never caught up
to that, and it has been permitting this invalid code for some time.
Stop permitting it, so that we give correct errors. Since we've
supported it for a long time, the compiler uses it in a couple of
cases: it predeclares the hash/equal methods if it decides to create
them while compiling another function, and it predeclares main.main as
a mechanism for getting the right warning if a program uses the wrong
signature for main. For simplicity, keep those existing uses.
This required a few minor changes in libgo which were relying,
unnecessarily, on the current behavior.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed
to mainline.
Ian