[PATCH] Enable _Static_assert inside structs/unions in C11 mode

John McCall rjmccall at apple.com
Thu Mar 28 10:45:25 PDT 2013


On Mar 28, 2013, at 1:22 AM, Andy Gibbs <andyg1001 at hotmail.co.uk> wrote:

> On Wednesday, March 27, 2013 9:09 PM, Richard Smith wrote:
> 
>> +    // Parse _Static_assert declaration.
>> +    if (Tok.is(tok::kw_static_assert) || Tok.is(tok::kw__Static_assert)) {
>> 
>> 
>> Any reason to check for _Static_assert here? This code is not reachable in
>> C++.
> 
> (I think you meant static_assert not _Static_assert!)
> 
> This is more in keeping with the fact that both are tested together throughout
> the code even where the code is not reachable in C and I would think it best
> to leave both in here also, just in case code paths change in future (for
> whatever reason) and since the additional check is hardly an expensive one.

Lots of hardly expensive checks can add up.  If you see a C++-specific check
in code only reachable in C, or vice-versa, take it out and add an assert on
the language mode.

John.



More information about the cfe-commits mailing list