public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14273] New: __attribute__ ((__unused__)) fails when attached to a label in c++
@ 2004-02-24 13:51 msp at nortelnetworks dot com
2004-02-24 14:02 ` [Bug c++/14273] " msp at nortelnetworks dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: msp at nortelnetworks dot com @ 2004-02-24 13:51 UTC (permalink / raw)
To: gcc-bugs
Bison 1.875 generates code which contains something like this:-
yyerrlab1:
__attribute__ ((__unused__))
Now this works for C compilation (ie. tells the compiler yyerrlab1 might not be
used, so stops the compiler generating a warning), but fails to compile for C++.
The following test code is similar to what bison does. It compiles for C, but
not for C++:-
void fred()
{
int x;
yyerrlab1:
__attribute__ ((__unused__))
x = 42;
}
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'
The documentation "Attribute Syntax" info node appears to say this should work:-
" An attribute specifier list may appear after the colon following a
label, other than a `case' or `default' label. The only attribute it
makes sense to use after a label is `unused'. This feature is intended
for code generated by programs which contains labels that may be unused
but which is compiled with `-Wall'. It would not normally be
appropriate to use in it human-written code, though it could be useful
in cases where the code that jumps to the label is contained within an
`#ifdef' conditional.
"
--
Summary: __attribute__ ((__unused__)) fails when attached to a
label in c++
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: msp at nortelnetworks dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: sparc-sun-solaris2.8
GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sparc-sun-solaris2.8
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14273
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/14273] __attribute__ ((__unused__)) fails when attached to a label in c++
2004-02-24 13:51 [Bug c++/14273] New: __attribute__ ((__unused__)) fails when attached to a label in c++ msp at nortelnetworks dot com
@ 2004-02-24 14:02 ` msp at nortelnetworks dot com
2004-02-24 14:10 ` msp at nortelnetworks dot com
2004-02-24 17:04 ` msp at nortelnetworks dot com
2 siblings, 0 replies; 4+ messages in thread
From: msp at nortelnetworks dot com @ 2004-02-24 14:02 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From msp at nortelnetworks dot com 2004-02-24 14:02 -------
After some searching I have established this has been raised before under bugid
11613. That bug has been marked FIXED, though as far as I can see it was really
rejected on the grounds that it can't be fixed.
BUT -
Is there an alternative syntax which will work for C++????
If so I can raise a bug/patch against bison so its parsers will compile in C++ mode.
Has the documentation been updated to reflect this limitation. The original
documentation was far from clear.
Cheers
Mark
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14273
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/14273] __attribute__ ((__unused__)) fails when attached to a label in c++
2004-02-24 13:51 [Bug c++/14273] New: __attribute__ ((__unused__)) fails when attached to a label in c++ msp at nortelnetworks dot com
2004-02-24 14:02 ` [Bug c++/14273] " msp at nortelnetworks dot com
@ 2004-02-24 14:10 ` msp at nortelnetworks dot com
2004-02-24 17:04 ` msp at nortelnetworks dot com
2 siblings, 0 replies; 4+ messages in thread
From: msp at nortelnetworks dot com @ 2004-02-24 14:10 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From msp at nortelnetworks dot com 2004-02-24 14:09 -------
nb. I have also found a comment on the mailing lists stating that
"
you can say
label __attribute__((unused)):
in both gcc and g++
"
BUT that fails to compile for me using g++ 3.3.3 in either C or C++ mode.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14273
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/14273] __attribute__ ((__unused__)) fails when attached to a label in c++
2004-02-24 13:51 [Bug c++/14273] New: __attribute__ ((__unused__)) fails when attached to a label in c++ msp at nortelnetworks dot com
2004-02-24 14:02 ` [Bug c++/14273] " msp at nortelnetworks dot com
2004-02-24 14:10 ` msp at nortelnetworks dot com
@ 2004-02-24 17:04 ` msp at nortelnetworks dot com
2 siblings, 0 replies; 4+ messages in thread
From: msp at nortelnetworks dot com @ 2004-02-24 17:04 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From msp at nortelnetworks dot com 2004-02-24 17:04 -------
*** This bug has been marked as a duplicate of 11613 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14273
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-02-24 17:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-24 13:51 [Bug c++/14273] New: __attribute__ ((__unused__)) fails when attached to a label in c++ msp at nortelnetworks dot com
2004-02-24 14:02 ` [Bug c++/14273] " msp at nortelnetworks dot com
2004-02-24 14:10 ` msp at nortelnetworks dot com
2004-02-24 17:04 ` msp at nortelnetworks dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).