xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/instantiate-blocks.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc // rdar: // 6182276
3*f4a2713aSLionel Sambuc 
foo(T t,T1 r)4*f4a2713aSLionel Sambuc template <typename T, typename T1> void foo(T t, T1 r)
5*f4a2713aSLionel Sambuc {
6*f4a2713aSLionel Sambuc     T block_arg;
7*f4a2713aSLionel Sambuc     __block T1 byref_block_arg;
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc     T1 (^block)(T)  =  ^ T1 (T arg) {
10*f4a2713aSLionel Sambuc          byref_block_arg = arg;
11*f4a2713aSLionel Sambuc          block_arg = arg; 	// expected-error {{variable is not assignable (missing __block type specifier)}}
12*f4a2713aSLionel Sambuc          return block_arg+arg; };
13*f4a2713aSLionel Sambuc }
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc // rdar://10466373
noret(T t,T1 r)16*f4a2713aSLionel Sambuc template <typename T, typename T1> void noret(T t, T1 r)
17*f4a2713aSLionel Sambuc {
18*f4a2713aSLionel Sambuc     (void) ^{
19*f4a2713aSLionel Sambuc     if (1)
20*f4a2713aSLionel Sambuc       return t;
21*f4a2713aSLionel Sambuc     else if (2)
22*f4a2713aSLionel Sambuc       return r;  // expected-error {{return type 'double' must match previous return type 'float' when block literal has unspecified explicit return type}}
23*f4a2713aSLionel Sambuc   };
24*f4a2713aSLionel Sambuc }
25*f4a2713aSLionel Sambuc 
main(void)26*f4a2713aSLionel Sambuc int main(void)
27*f4a2713aSLionel Sambuc {
28*f4a2713aSLionel Sambuc     foo(100, 'a');	// expected-note {{in instantiation of function template specialization 'foo<int, char>' requested here}}
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc    noret((float)0.0, double(0.0)); // expected-note {{in instantiation of function template specialization 'noret<float, double>' requested here}}
31*f4a2713aSLionel Sambuc }
32*f4a2713aSLionel Sambuc 
33