]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR go/49889 (Calling a function whose name is obscured by a local variable does...
authorNick Clifton <nickc@redhat.com>
Wed, 27 Apr 2016 11:29:20 +0000 (11:29 +0000)
committerNick Clifton <nickc@gcc.gnu.org>
Wed, 27 Apr 2016 11:29:20 +0000 (11:29 +0000)
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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr49899.c [new file with mode: 0644]
gcc/varasm.c

index a12ae4e1dc7f4ba9ffb865c2d429831f7d7cac16..ed251d2cdc372a79a419a7d652d51b4acca7c55a 100644 (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.
index 6fd6cfa6669edd1aa183c5db395a289bb0d93369..4752a4cb069b9ec7b882e647abef8627d72a4517 100644 (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.
diff --git a/gcc/testsuite/gcc.dg/pr49899.c b/gcc/testsuite/gcc.dg/pr49899.c
new file mode 100644 (file)
index 0000000..b5b3259
--- /dev/null
@@ -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));
+
index c7ed06e549af6624ea2e8bb0472b6b986124dbf9..4a7124e73be5fffe1b85a137e25ade1aae508e2d 100644 (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.