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

John McCall rjmccall at apple.com
Tue Aug 14 13:03:28 PDT 2012


On Aug 14, 2012, at 11:59 AM, Hans Wennborg wrote:
> On Tue, Aug 14, 2012 at 6:28 PM, John McCall <rjmccall at apple.com> wrote:
>> Looks great, thanks!  Might as well add a test for the function and block-pointer
>> cases (to verify that an error is emitted, but not this one), but feel free to commit.
> 
> Now that I start playing with it, I don't seem to get any errors for
> the block-pointer case. I'm not very familiar with these things, but I
> think that this:
> 
>  void f(int (^x[10])());
> 
> declares a function f that takes a parameter x, which is an array of
> block pointers that return int. Clang doesn't give an error here
> (assuming I use -fblocks of course). Should it?

No;  the array type here will be "decayed" to a pointer type.

> And should it give an error for this:
> 
>  void f(int (^x[static 10])());

No.

The case I had in mind was something like this:
   void f(int (^x)[static 10]);
This is ill-formed because you can't form a block pointer to array type.

The function case would be something like this:
  void f(int x()[static 10])
This is an ill-formed array of functions.

In both cases, we don't want to mask the "more serious" error by
complaining about 'static' first.

John.



More information about the cfe-commits mailing list