1 // RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s
2
foo(T t,T1 r)3 template <typename T, typename T1> void foo(T t, T1 r)
4 {
5 T block_arg;
6 __block T1 byref_block_arg;
7
8 T1 (^block)(T) = ^ T1 (T arg) {
9 byref_block_arg = arg;
10 block_arg = arg; // expected-error {{variable is not assignable (missing __block type specifier)}}
11 return block_arg+arg; };
12 }
13
noret(T t,T1 r)14 template <typename T, typename T1> void noret(T t, T1 r)
15 {
16 (void) ^{
17 if (1)
18 return t;
19 else if (2)
20 return r; // expected-error {{return type 'double' must match previous return type 'float' when block literal has unspecified explicit return type}}
21 };
22 }
23
main(void)24 int main(void)
25 {
26 foo(100, 'a'); // expected-note {{in instantiation of function template specialization 'foo<int, char>' requested here}}
27
28 noret((float)0.0, double(0.0)); // expected-note {{in instantiation of function template specialization 'noret<float, double>' requested here}}
29 }
30
31 namespace rdar41200624 {
32 template <class T>
33 struct S {
34 int (^p)() = ^{ return 0; };
35 T (^t)() = ^{ return T{}; };
36 T s = ^{ return T{}; }();
37 };
38 S<int> x;
39 }
40