[CodeGenPrepare] Drop nsw flags in `optimizeLoadExt` (#118180)
[llvm-project.git] / clang / test / SemaCXX / instantiate-blocks.cpp
blob3e07c349f0a1c0ffee72bbde363436c3dbaa5a7a
1 // RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s
3 template <typename T, typename T1> void foo(T t, T1 r)
5 T block_arg;
6 __block T1 byref_block_arg;
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; };
14 template <typename T, typename T1> void noret(T t, T1 r)
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}}
24 int main(void)
26 foo(100, 'a'); // expected-note {{in instantiation of function template specialization 'foo<int, char>' requested here}}
28 noret((float)0.0, double(0.0)); // expected-note {{in instantiation of function template specialization 'noret<float, double>' requested here}}
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{}; }();
38 S<int> x;