Exact gcc version (Fedora 8): gcc (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33) Following small code snippet: static void remove_one(void); static void __attribute__((__used__)) remove_one(void) { } build with: gcc -c -Wall test.c produces following warning: test.c:4: warning: ‘remove_one’ defined but not used Removing the forward declaration (prototye) or adding the attribute to the forward declaration make the warning disappear. I had expected the attribution on the function to take precedence over the forward declaration. Browsing the gcc manual did not reveal an answer and searching the web / the bug database did not bring up an answer so I decided to report it as a bug. /Sam
Confirmed. Not a regression.
Patch here: http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00044.html I miss the patch tracker :(
Subject: Bug 34985 Author: manu Date: Tue Jul 29 10:00:25 2008 New Revision: 138235 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=138235 Log: 2008-07-29 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR 34985 * c-decl.c (merge_decls): Merge USED flags. cp/ * decl.c (duplicate_decls): Merge USED flags. testsuite/ * gcc.dg/pr34985.c: New. * g++.dg/warn/pr34985.C: New. Added: trunk/gcc/testsuite/g++.dg/warn/pr34985.C trunk/gcc/testsuite/gcc.dg/pr34985.c Modified: trunk/gcc/ChangeLog trunk/gcc/c-decl.c trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Fixed in GCC 4.4