From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11478 invoked by alias); 24 Feb 2004 13:51:38 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 11454 invoked by uid 48); 24 Feb 2004 13:51:32 -0000 Date: Tue, 24 Feb 2004 13:51:00 -0000 From: "msp at nortelnetworks dot com" To: gcc-bugs@gcc.gnu.org Message-ID: <20040224135128.14273.msp@nortelnetworks.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/14273] New: __attribute__ ((__unused__)) fails when attached to a label in c++ X-Bugzilla-Reason: CC X-SW-Source: 2004-02/txt/msg02283.txt.bz2 List-Id: 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