Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks |
Steve Naroff | 1f3b0d5 | 2008-09-10 18:33:00 +0000 | [diff] [blame] | 2 | |
| 3 | void take(void*); |
| 4 | |
| 5 | void test() { |
| 6 | take(^(int x){}); |
| 7 | take(^(int x, int y){}); |
| 8 | take(^(int x, int y){}); |
| 9 | take(^(int x, int x){}); // expected-error {{redefinition of parameter 'x'}} |
| 10 | |
| 11 | |
| 12 | take(^(int x) { return x+1; }); |
| 13 | |
| 14 | int (^CP)(int) = ^(int x) { return x*x; }; |
| 15 | take(CP); |
| 16 | |
| 17 | int arg; |
| 18 | ^{return 1;}(); |
| 19 | ^{return 2;}(arg); // expected-error {{too many arguments to block call}} |
| 20 | ^(void){return 3;}(1); // expected-error {{too many arguments to block call}} |
Eli Friedman | 687abff | 2009-06-08 04:24:21 +0000 | [diff] [blame] | 21 | ^(){return 4;}(arg); // expected-error {{too many arguments to block call}} |
Steve Naroff | 1f3b0d5 | 2008-09-10 18:33:00 +0000 | [diff] [blame] | 22 | ^(int x, ...){return 5;}(arg, arg); // Explicit varargs, ok. |
| 23 | } |
| 24 | |
John McCall | 13591ed | 2009-07-25 04:36:53 +0000 | [diff] [blame] | 25 | int main(int argc, char** argv) { |
Steve Naroff | ae530cf | 2008-09-28 14:02:55 +0000 | [diff] [blame] | 26 | ^(int argCount) { |
| 27 | argCount = 3; |
| 28 | }(argc); |
| 29 | } |