aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2016-04-27 11:29:20 +0000
committerNick Clifton <nickc@gcc.gnu.org>2016-04-27 11:29:20 +0000
commit9ec5d66b5daec672f1194f1e15a31a7636915c87 (patch)
treec69639793f1984427b5b0b349f8a3377588e2da7 /gcc/varasm.c
parent2e885a6f7ce629d6517c2bf8dc14824be8e93987 (diff)
downloadgcc-9ec5d66b5daec672f1194f1e15a31a7636915c87.zip
gcc-9ec5d66b5daec672f1194f1e15a31a7636915c87.tar.gz
gcc-9ec5d66b5daec672f1194f1e15a31a7636915c87.tar.bz2
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
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index c7ed06e..4a7124e 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -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.