40 lines · cpp
1// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s2 3template <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 14template <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 24int 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 31namespace rdar41200624 {32template <class T>33struct S {34 int (^p)() = ^{ return 0; };35 T (^t)() = ^{ return T{}; };36 T s = ^{ return T{}; }();37};38S<int> x;39}40