re PR go/49889 (Calling a function whose name is obscured by a local variable does not produce an error)

PR middle-end/49889
gcc	* varasm.c (merge_weak): Generate an error if an attempt is made
	to convert a non-weak static function into a weak, public function.

testsuite	* gcc.dg/pr49889.c: New test.

From-SVN: r235484
This commit is contained in:
Nick Clifton 2016-04-27 11:29:20 +00:00 committed by Nick Clifton
parent 2e885a6f7c
commit 9ec5d66b5d
4 changed files with 19 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2016-04-27 Nick Clifton <nickc@redhat.com>
PR middle-end/49889
* varasm.c (merge_weak): Generate an error if an attempt is made
to convert a non-weak static function into a weak, public function.
2016-04-27 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
* params.def (MAX_PARTITION_SIZE): New param.

View File

@ -1,3 +1,8 @@
2016-04-27 Nick Clifton <nickc@redhat.com>
PR middle-end/49889
* gcc.dg/pr49889.c: New test.
2016-04-27 Bernd Schmidt <bschmidt@redhat.com>
* c-c++-common/memset-array.c: New test.

View File

@ -0,0 +1,3 @@
static int foo (void) { return 0; } /* { dg-error "weak declaration of 'foo' being applied to a already existing, static definition" } */
int foo (void) __attribute__((weak));

View File

@ -5371,6 +5371,11 @@ merge_weak (tree newdecl, tree olddecl)
gcc_assert (!TREE_USED (olddecl)
|| !TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)));
/* PR 49899: You cannot convert a static function into a weak, public function. */
if (! TREE_PUBLIC (olddecl) && TREE_PUBLIC (newdecl))
error ("weak declaration of %q+D being applied to a already "
"existing, static definition", newdecl);
if (TARGET_SUPPORTS_WEAK)
{
/* We put the NEWDECL on the weak_decls list at some point.