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]

[Bug c++/5026] __attribute__ ((unused) seems misdocumented


------- 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


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