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

Andy Gibbs andyg1001 at hotmail.co.uk
Wed Apr 3 03:17:17 PDT 2013


Hi,

Ok, its committed in r178632.  I took out the additional check as requested
by Richard and merged in the test-case into test/Sema/static-assert.c, but
I retained the fact that the test runs also in C++ mode since there seemed
not to be any coverage given to the fact that _Static_assert can also be
used in C++ mode (as opposed to static_assert).  If this remains a problem,
of course it can easily be remedied!

Thanks for your input.

Andy


On Thursday, March 28, 2013 10:22 AM, Andy Gibbs 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.
>
> On a separate point though, I'm not sure clang needs both 
> tok::kw_static_assert and tok::kw__Static_assert since they are always
> paired together (except in one place).  Is it important to keep them
> separate, or could I merge them into one?
>
>> +++ clang/test/Sema/static-assert2.c
>>
>>
>> Please add the tests to test/Sema/static-assert.c instead. We don't need 
>> to run these tests in C++ mode; we already have good coverage for C++11's
>> static_assert.
>
> As you wish; I had split it out to show that the diagnostics and support 
> were the same in both C and C++ for the same code.
>
> Let me know your thoughts on tok::kw__Static_assert above, and I'll commit
> later today.
>
> Cheers
> Andy 




More information about the cfe-commits mailing list