[cfe-commits] [Patch] Produce errors for 'static' and type qualifiers in array declarators

Hans Wennborg hans at chromium.org
Sun Aug 12 08:20:09 PDT 2012


Thanks for the review! New patch attached.

On Sat, Aug 11, 2012 at 8:14 PM, John McCall <rjmccall at apple.com> wrote:
> +        unsigned x = chunkIndex;
> +        for (;;) {
> +          // Walk outwards along the declarator chunks.
> +          if (x == 0)
> +            break;
> +          x--;
>
> This can just be
>   while (x != 0) {
>     x--;

Yeah, that's better.

> +          switch (DC.Kind) {
> +          case DeclaratorChunk::Paren:
> +            continue;
> +          case DeclaratorChunk::Array:
> +          case DeclaratorChunk::Pointer:
>
> We try to avoid 'default' cases, and this is a good example why.  I claim
> that there are no declarator chunks which are actually valid here except
> Paren.

Right.

> Suppressing the error when the chunk is a Function or BlockPointer
> is fine, since we'll still get the more-important diagnostic that the type is
> invalid.  We should not suppress the error when the chunk is Reference
> or MemberPointer, though.

I was thinking that in these cases we would get errors about trying to
use a C99 feature in C++, but maybe it's better not to ignore it.

> Also, if someone adds a new declarator chunk
> (not entirely impossible), they should have to consider what to do in this
> case.

That's a good point.

Thanks,
Hans
-------------- next part --------------
A non-text attachment was scrubbed...
Name: static_in_array_decls3.patch
Type: application/octet-stream
Size: 5258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120812/39345e10/attachment.obj>


More information about the cfe-commits mailing list