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