C++11 attributes for C11 (was Re: [PATCH] Generalized attribute support)

Richard Smith richard at metafoo.co.uk
Wed Apr 23 10:50:02 PDT 2014


On Wed, Apr 23, 2014 at 1:45 AM, Jean-Daniel Dupas
<devlists at shadowlab.org>wrote:

>
> Le 22 avr. 2014 à 22:45, Nico Weber <thakis at chromium.org> a écrit :
>
> On Sat, Apr 19, 2014 at 4:05 PM, Alp Toker <alp at nuanti.com> wrote:
>
>> Small update for the list..
>>
>> We discussed this at LLVM Europe 2014 and came to the conclusion that we
>> might as well offer the feature behind an -f flag.
>>
>> This should satisfy user requests for C++11-style attributes in C11
>> without prejudicing any standards process. Thanks to the many detailed
>> use-cases people sent in that have made me more comfortable picking this up
>> again.
>>
>
> Are these use-cases visible anywhere?
>
>
>
> [[clang::fallthough]] ?
>

We could support that in C by allowing GNU __attribute__s on statements, or
by adding a __builtin_fallthrough() function or a __fallthrough keyword, or
by recognizing /* Fall through. */ comments. (There's prior art for at
least the latter two of these options.) Allowing C++ attributes in C is not
the only way to provide this functionality; is it better than the
alternatives?

It's not obvious to me that we want C++ attributes for the capability
attributes: C++ attributes on function declarations appear *before* the
parameter-declaration-clause, making them a worse choice for attributes
that might name function parameters than GNU attributes. These attributes
will be wrapped by a macro anyway, so an end user won't see the syntactic
difference between the two approaches. And the C++ attributes in C
extension, if we provide it, will be off by default. This seems like a hard
sell. What's the upside?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140423/e6db0612/attachment.html>


More information about the cfe-commits mailing list