This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/7101: attribute unused not honored on static variable preceeded by extern declaration


>Number:         7101
>Category:       c
>Synopsis:       attribute unused not honored on static variable preceeded by extern declaration
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 21 13:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Kaveh Ghazi
>Release:        gcc version 3.2 20020620 (experimental)
>Organization:
>Environment:
probably all (but at least on sparc-sun-solaris2.7)
>Description:
I've written the following testcase suitable for installation as gcc.dc/unused-#.c when its been fixed.  currently, if you compile this code you get 'defined but not used' warnings for all three variables.  (Given the attributes, you should only get it for i1.)

This is the cause of a warning from libobjc/encoding.c, where even though the `target_flags' variable has attribute unused set on it you still get this message:
 > libobjc/encoding.c:83: warning: `target_flags' defined 

Here's what the testcase below yields:

 > unused-5.c:8: warning: `i1' defined but not used
 > unused-5.c:9: warning: `i2' defined but not used
 > unused-5.c:10: warning: `i3' defined but not used


/* { dg-do compile } */
/* { dg-options "-Wunused -O2" } */

#define UNUSED __attribute__ ((__unused__))

extern int i1, i2, i3;

static int i1 = 0;              /* { dg-warning "defined but not used" } */
static int UNUSED i2 = 0;
static int i3 UNUSED = 0;
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]