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


Sean Hunt <rideau3@gmail.com> writes:

> On 07/10/2010 03:56 PM, Ian Lance Taylor wrote:
>> Sean Hunt<rideau3@gmail.com>  writes:
>>
>>>      void foo () __attribute__((noreturn)); // right per spec
>>>      void foo __attribute__((noreturn)) (); // works
>>>      __attribute__((noreturn)) void foo (); // works
>>>
>>> It's obvious that the first example of each kind (noreturn appearing
>>> after the function declarator) must be accepted if it's a GCC
>>> attribute and not if it's a C++0x attributes. The later two (noreturn
>>> appearing before the declaration or after the identifier) must be
>>> accepted for C++0x attributes, but it's not clear if the GCC syntax
>>> being accepted is an accident or by design.
>>
>> As far as I can see they are both documenated as working at
>> http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Attribute-Syntax.html , so I
>> think it is by design.
>
> The problem is that it is not clear if that is intended, or merely an
> accident. The spec is rather unclear about a number of things.

I'm not sure what sort of answer you are looking for.  Attributes were
implemented in gcc without any sort of design or spec.  They were and
are used in many programs.  We don't want to break those programs.  The
current documentation describes how attributes work, and is intended to
be a guide both for gcc maintainers and for gcc users.  The
documentation describes for users how attributes may be used, and
describes for maintainers what is supposed to work.

So when you ask whether the syntax is intended or is an accident, the
answer is more or less that both are the case.  It's not an either/or
situation.


>>> Is anyone currently working on C++0x attributes in GCC and, if not, is
>>> there anyone who can help me through what we should and shouldn't
>>> accept in clang?
>>
>> I don't know the answer to this.  It's clear that C++0x attributes are
>> not the same as GNU attributes.
>
> Yes. I'm trying to determine which parts of GCC attributes are merely
> accidents and don't really need implementation, as there are a lot of
> situations where GCC attributes (as implemented) are significantly
> more liberal than C++0x attributes are. This will be an issue that GCC
> developers will encounter when an effort is made to implement
> attributes; I would like to see what discussion can be had before I go
> ahead and reimplement the attribute codepaths within clang.

I'm not working on implementing C++0x attributes in GCC.  However, my
answer would be that you should implement gcc attributes according to
the gcc docs and implement C++0x attributes according to the C++0x final
committee draft.  They are obviously related, but they are not the same
thing.  It would be a mistake to implement them both in the same way, at
least when it comes to syntax.

Ian


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