[PATCH] Generalized attribute support

Alp Toker alp at nuanti.com
Wed Jan 15 12:44:46 PST 2014


On 15/01/2014 20:29, Richard Smith wrote:
> On Wed Jan 15 2014 at 3:42:08 AM, Alp Toker <alp at nuanti.com 
> <mailto:alp at nuanti.com>> 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.
>
>
> Weird. The impression I get is that nobody is doing it (at least, not 
> publically).

People said they were patching internally to use new security and 
optimization attributes, and presumably there are others ("nobody's 
talking about it"). Seems a reasonable use case.

>
> What if a future revision of a standard we care about (maybe C, 
> OpenMP, OpenCL, CUDA, ...) standardizes a *different* meaning for 
> square brackets? Code that used our extension would be in trouble.

This is a great reason to hold back from switching it on globally.

If we don't have "nudge" power in getting this as a de-facto C1y feature 
it becomes less interesting.

>
> This isn't even purely theoretical -- Objective-C does this, and it is 
> essentially only by luck that it's possible to disambiguate this 
> fully. As another example, if C17 took C++'s lambdas but not its 
> attributes, we'd run into some amount of trouble with expressions like
>
>  int x[ [] { ... } () ];
>
> (which is an ill-formed attribute under the C++11 rules).

It'd be far from the worst disambiguation we have in-tree.

Objective-C disambiguation is working fine with the C11 extension 
enabled for what it's worth.

I'm withdrawing the patch, there are probably more useful things to be 
working on.

Tentatively setting a date to revisit this in a years time or after gcc 
implements, whichever comes first, when there might be a clearer way 
forward.

Alp.


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




More information about the cfe-commits mailing list