Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s |
Andy Gibbs | 8e8fb3b | 2012-10-19 12:44:48 +0000 | [diff] [blame] | 2 | // expected-no-diagnostics |
Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 3 | |
| 4 | int printf(char const *, ...); |
Steve Naroff | 5618bd4 | 2008-08-27 16:04:49 +0000 | [diff] [blame] | 5 | |
| 6 | struct blockStruct { |
| 7 | int (^a)(float, int); |
| 8 | int b; |
| 9 | }; |
| 10 | |
| 11 | int blockTaker (int (^myBlock)(int), int other_input) |
| 12 | { |
Steve Naroff | 296e8d5 | 2008-08-28 19:20:44 +0000 | [diff] [blame] | 13 | return 5 * myBlock (other_input); |
Steve Naroff | 5618bd4 | 2008-08-27 16:04:49 +0000 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | int main (int argc, char **argv) |
| 17 | { |
Steve Naroff | 296e8d5 | 2008-08-28 19:20:44 +0000 | [diff] [blame] | 18 | int (^blockptr) (int) = ^(int inval) { |
| 19 | printf ("Inputs: %d, %d.\n", argc, inval); |
| 20 | return argc * inval; |
| 21 | }; |
| 22 | |
| 23 | |
| 24 | argc = 10; |
| 25 | printf ("I got: %d.\n", |
| 26 | blockTaker (blockptr, 6)); |
Steve Naroff | 5618bd4 | 2008-08-27 16:04:49 +0000 | [diff] [blame] | 27 | return 0; |
| 28 | } |
| 29 | |