This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/5026] __attribute__ ((unused) seems misdocumented
- From: "msp at nortelnetworks dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Feb 2004 13:37:33 -0000
- Subject: [Bug c++/5026] __attribute__ ((unused) seems misdocumented
- References: <20011205204601.5026.bh@techhouse.brown.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From msp at nortelnetworks dot com 2004-02-24 13:37 -------
(In reply to comment #11)
> Actually now with 3.4.0 the part about C++ is wrong because now you can use
the attribute in
> C++. The problem is that the attribute can be put on variables also not just
functions.
Actually for C the attribute can also be applied to labels! BUT not for C++.
The following code (based on the default output from bison 1.875), will compile
in C mode, but not in C++ mode:-
void fred()
{
int x;
yyerrlab1:
__attribute__ ((__unused__))
1 x = 42;
}
The intention is to tell the compiler that yyerrlab1: may be unused, but in C++
mode you get the following error:-
p.cc: In function `void fred()':
p.cc:8: error: ISO C++ forbids declaration of `x' with no type
p.cc:8: error: redeclaration of `int x'
p.cc:3: error: `int x' previously declared here
p.cc:8: error: declaration of `int x'
p.cc:3: error: conflicts with previous declaration `int x'
It also allows its use And even more cunningly it can (or should be) possible to
attach it to labels.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5026