blob: 08af9b377361ff0669dce7a5f3ba1d22ce5993ac [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
Steve Naroff1f3b0d52008-09-10 18:33:00 +00002
3void take(void*);
4
5void 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 Friedman687abff2009-06-08 04:24:21 +000021 ^(){return 4;}(arg); // expected-error {{too many arguments to block call}}
Steve Naroff1f3b0d52008-09-10 18:33:00 +000022 ^(int x, ...){return 5;}(arg, arg); // Explicit varargs, ok.
23}
24
John McCall13591ed2009-07-25 04:36:53 +000025int main(int argc, char** argv) {
Steve Naroffae530cf2008-09-28 14:02:55 +000026 ^(int argCount) {
27 argCount = 3;
28 }(argc);
29}