On Sep 24, 2008, at 9:32 PM, Mike Stump wrote:

On Sep 24, 2008, at 6:08 PM, steve naroff wrote:
On Sep 24, 2008, at 9:00 PM, Mike Stump wrote:

On Sep 24, 2008, at 4:31 PM, Steve Naroff wrote:
New Revision: 56595

Downgrade incompatible block pointer error to a warning (to be consistent with incompatible pointer warnings in general).

:-( In gcc these are all hard errors I believe, and I think in clang they should be hard errors as well. Strong typing in this case I don't think poses a problem.


I don't think you are correct. Can you please check and get back to me.

snaroff

- short (^add1)(void) = ^{ return y+1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(void)', expected 'short (^)(void)'}} + short (^add1)(void) = ^{ return y+1; }; // expected-warning {{incompatible block pointer types initializing 'int (^)(void)', expected 'short (^)(void)'}}

I did that before I sent the email:

$ cat t4.c
main() {
 int y;
 short (^add1)(void) = ^{ return y+1; };
}
mrs $ gcc -fblocks -xc++ t4.c -c
t4.c: In function ‘int main()’:
t4.c:3: error: cannot convert ‘int (^)()’ to ‘short int (^)()’ in initialization
mrs $ gcc -fblocks -xc t4.c -c
t4.c: In function ‘main’:
t4.c:3: error: incompatible block pointer types initializing ‘int (^) (void)’, expected ‘short int (^)(void)’

Pretty clear to me.

Thanks! Unfortunately, this means the following will be considered an error.

void foo() {
  int (^xx)(const char *s) = ^(char *s) { return 1; };
}

Can you try this this on your gcc? (I don't have it handy).

Fariborz said we should treat this the same as function pointer assignments (which is why I made the change...).

Fariborz, feel free to chime in:-)

snaroff
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to