[PATCH] Generalized attribute support

Alp Toker alp at nuanti.com
Wed Jan 15 07:18:17 PST 2014


On 15/01/2014 14:58, Aaron Ballman wrote:
> On Wed, Jan 15, 2014 at 6:59 AM, Alp Toker <alp at nuanti.com> wrote:
>> On 15/01/2014 11:41, Alp Toker wrote:
>>>
>>> On 15/01/2014 06:04, Nico Weber wrote:
>>>> Does gcc allow this for C? Is C planning on standardizing this?
>>>
>>> The impression I get is that everybody's doing it but nobody's talking
>>> about it. Yet.
>>>
>>> ISO C is reactionary so if we set a sensible standard there's a reasonable
>>> shot at getting it adopted. Likewise OpenMP and other dialects -- they'll go
>>> with the mainstream.
>>>
>>> This is also why we should use a name that's already recognised like
>>> "generalized attributes." Language bodies simply won't accept a foreign name
>>> like "C++ attributes" -- it has never happened before, given how fiercely
>>> independent these committees are -- so they'll end up each going their own
>>> route, choosing their own names. It's a better plan to consolidate
>>> proactively here.
>>
>> To be clear, this isn't just about naming. The syntaxes will also end up
>> differing if we end up with disparate "C++ attributes", "OpenMP attributes",
>> "OpenCL attributes" (?), "C attributes"  -- potentially a bunch of different
>> specifications and quirky parse rules with no way out.
> We're already in this situation today, even within the "same"
> language. C++11 uses [[]] while C++/CLI uses [].

For what it's worth we have both C++ and C++/CLI syntaxes supported 
cooperatively in the Nuanti C++/CLI compiler product.

Looking at our implementation now, it's just a routine check in the 
parser (one bracket is for C++/CLI, two are for C++11). Doesn't even 
requiring disambiguation, except that the C++/CLI syntax can only appear 
on declarations.


>   The last time this
> came up in the C committee (from what I understand) was 2009 (N1403)
> and leaned towards __attribute__ as the specifier. So I don't think
> there's a way we can push this as a cross-language "generalized"
> attribute feature.

That's not surprising -- there wasn't a generalized solution back in 
2009. The C++/CLI syntax which would have been the most viable at the 
time wasn't suitable for use in attributed statements due to ambiguity.

Alp.


>
> ~Aaron

-- 
http://www.nuanti.com
the browser experts




More information about the cfe-commits mailing list