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

Andy Gibbs andyg1001 at hotmail.co.uk
Thu Mar 28 01:22:31 PDT 2013


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