This is the mail archive of the gcc-patches@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]

Re: [gcc-in-cxx] Permit __attribute__ ((unused)) on labels in C++


"Joseph S. Myers" <joseph@codesourcery.com> writes:

> On Tue, 10 Feb 2009, Ian Lance Taylor wrote:
>
>> The generated file insn-recog.c contains a lot of unused labels.  These
>> are marked with ATTRIBUTE_UNUSED_LABEL.  That attribute is not supported
>> by current g++, causing a -Werror failure when building with C++.  This
>> patch adds support for __attribute__ ((unused)) on labels to the C++
>> compiler.  Committed to gcc-in-cxx branch.
>
> You need to update extend.texi where it says "GNU C++ does not permit such 
> placement of attribute lists, as it is permissible for a declaration, 
> which could begin with an attribute list, to be labelled in C++.".  What 
> do you do if the label in question is followed by a declaration?  And is 
> this consistent with the attributes support in C++0x?

I'll worry about the docs, and test cases, when I propose the patch for
mainline.  But I didn't realize that there was an ambiguity here.  That
does seem to be a problem.  This test case:

void quux() { a: __attribute__ ((unused)) int i; }

gives this warning in mainline:

foo.cc:1: warning: label âaâ defined but not used

and this warning in gcc-in-cxx branch:

foo.cc:1: warning: unused variable âiâ

This seems unfortunate.  We could simply declare by fiat that attributes
following a label are associated with the label, although that it is
conceivable that that would change the behaviour of existing code.  Or I
could simply revert my patch--although being able to declare a label to
be unused does seem generally useful--and find some other way to fix the
problem.  I don't know what C++0x says.

Any thoughts on the best approach?

Ian


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