[cfe-commits] r56595 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaExpr.cpp test/Sema/block-call.c test/Sema/block-return.c

steve naroff snaroff at apple.com
Thu Sep 25 13:24:11 PDT 2008


On Sep 25, 2008, at 2:49 PM, Mike Stump wrote:

> On Sep 25, 2008, at 3:13 AM, steve naroff wrote:
>> Thanks!  Unfortunately, this means the following will be considered  
>> an error.
>>
>> void foo() {
>>  int (^xx)(const char *s) = ^(char *s) { return 1; };
>> }
>
> The pointer version of this is a violation of the C and C++  
> standards.  Blocks should be the same way.
>
>> Can you try this on your gcc? (I don't have it handy).
>
> With -ansi -pedantic-errors and pointers, they both error out in  
> gcc.  As blocks, in C++ it gives an error.

O.k. I'm happy to change it back to an error.

> In C, it just swallows it, no warning even.  The C behavior is  
> wrong, I filed 6246965 to cover it.  The C++ behavior is as expected.
>

The broken C behavior in GCC is what motivated my change. Since we are  
compiling blocks code with both gcc & clang, I want to make sure we  
are source compatible. I shouldn't assume GCC is bug free:-)

So...whatever we do with type checking blocks, gcc and clang need to  
agree.

>> Fariborz said we should treat this the same as function pointer  
>> assignments (which is why I made the change...).
>
> Ah, but there is a laxity that I don't think he meant to include.   
> Blocks don't need this laxity as there isn't 30 year old dusty deck  
> blocks code.  Also, laxity for const violations is, well, a - 
> fpermissive type thang.

Makes sense. Thanks for catching this!

snaroff



More information about the cfe-commits mailing list