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
+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.
+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.
--- /dev/null
+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));
+
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.