Bug 34985 - Warning "defined but not used" despite __attribute__((__used__))
Warning "defined but not used" despite __attribute__((__used__))
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c
4.1.2
: P3 enhancement
: 4.4.0
Assigned To: Manuel López-Ibáñez
: diagnostic, patch
Depends on:
Blocks: 4.4pending
  Show dependency treegraph
 
Reported: 2008-01-26 19:28 UTC by Sam Ravnborg
Modified: 2008-12-29 14:48 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.3.0
Last reconfirmed: 2008-02-02 12:52:41


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Ravnborg 2008-01-26 19:28:55 UTC
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
Comment 1 Richard Biener 2008-01-26 20:09:33 UTC
Confirmed.  Not a regression.
Comment 2 Manuel López-Ibáñez 2008-02-02 12:52:41 UTC
Patch here: http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00044.html

I miss the patch tracker :(
Comment 3 Manuel López-Ibáñez 2008-07-29 10:01:18 UTC
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

Comment 4 Manuel López-Ibáñez 2008-07-29 10:08:32 UTC
Fixed in GCC 4.4