xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/instantiate-blocks.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fblocks -emit-llvm -o - %s
2*f4a2713aSLionel Sambuc // rdar : // 6182276
3*f4a2713aSLionel Sambuc 
foo(T t)4*f4a2713aSLionel Sambuc template <typename T> T foo(T t)
5*f4a2713aSLionel Sambuc {
6*f4a2713aSLionel Sambuc     void (^block)(int);
7*f4a2713aSLionel Sambuc     return 1;
8*f4a2713aSLionel Sambuc }
9*f4a2713aSLionel Sambuc 
test1(void)10*f4a2713aSLionel Sambuc int test1(void)
11*f4a2713aSLionel Sambuc {
12*f4a2713aSLionel Sambuc     int i = 1;
13*f4a2713aSLionel Sambuc     int b = 2;
14*f4a2713aSLionel Sambuc     i = foo(b);
15*f4a2713aSLionel Sambuc     return 0;
16*f4a2713aSLionel Sambuc }
17*f4a2713aSLionel Sambuc 
foo(T t,T1 r)18*f4a2713aSLionel Sambuc template <typename T, typename T1> void foo(T t, T1 r)
19*f4a2713aSLionel Sambuc {
20*f4a2713aSLionel Sambuc     T block_arg;
21*f4a2713aSLionel Sambuc     __block T1 byref_block_arg;
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc     T1 (^block)(char, T, T1, double) =
24*f4a2713aSLionel Sambuc 	^ T1 (char ch, T arg, T1 arg2, double d1) { byref_block_arg = arg2;
25*f4a2713aSLionel Sambuc            					    return byref_block_arg + block_arg + arg; };
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc     void (^block2)() = ^{};
28*f4a2713aSLionel Sambuc }
29*f4a2713aSLionel Sambuc 
test2(void)30*f4a2713aSLionel Sambuc void test2(void)
31*f4a2713aSLionel Sambuc {
32*f4a2713aSLionel Sambuc     foo(100, 'a');
33*f4a2713aSLionel Sambuc }
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc namespace rdar6182276 {
36*f4a2713aSLionel Sambuc extern "C" {
37*f4a2713aSLionel Sambuc int printf(const char *, ...);
38*f4a2713aSLionel Sambuc }
39*f4a2713aSLionel Sambuc 
foo(T t)40*f4a2713aSLionel Sambuc template <typename T> T foo(T t)
41*f4a2713aSLionel Sambuc {
42*f4a2713aSLionel Sambuc     void (^testing)(int) = ^(int bar) { printf("bar is %d\n", bar); };
43*f4a2713aSLionel Sambuc     printf("bar is\n");
44*f4a2713aSLionel Sambuc     return 1;
45*f4a2713aSLionel Sambuc }
46*f4a2713aSLionel Sambuc 
gorf(T t)47*f4a2713aSLionel Sambuc template <typename T> void gorf(T t)
48*f4a2713aSLionel Sambuc {
49*f4a2713aSLionel Sambuc     foo(t);
50*f4a2713aSLionel Sambuc }
51*f4a2713aSLionel Sambuc 
52*f4a2713aSLionel Sambuc 
test(void)53*f4a2713aSLionel Sambuc void test(void)
54*f4a2713aSLionel Sambuc {
55*f4a2713aSLionel Sambuc     gorf(2);
56*f4a2713aSLionel Sambuc }
57*f4a2713aSLionel Sambuc }
58*f4a2713aSLionel Sambuc 
59*f4a2713aSLionel Sambuc 
60