[InstCombine] Preserve NSW flags for `lshr (mul nuw X, C1), C2 -> mul nuw nsw X,...
[llvm-project.git] / clang / test / CodeGenCXX / reference-in-blocks.cpp
blobf5cc566e7e50c521a200974980525ed09c1595c1
1 // RUN: %clang_cc1 -fblocks %s -emit-llvm -o %t
3 extern "C" int printf(const char*, ...);
5 template<typename T> class range {
6 public:
7 T _i;
8 range(T i) {_i = i;};
9 T get() {return _i;};
12 class A {
13 public:
14 A() : field(10), d1(3.14) {}
15 void F();
16 void S() {
17 printf(" field = %d\n", field);
18 printf(" field = %f\n", d1);
20 int field;
21 double d1;
24 void A::F()
26 __block A &tlc = *this;
27 // crashed in code gen
28 ^{ tlc.S(); }();
31 int main() {
33 // works
34 void (^bl)(range<int> ) = ^(range<int> i){printf("Hello Blocks %d\n", i.get()); };
36 //crashes in godegen?
37 void (^bl2)(range<int>& ) = ^(range<int>& i){printf("Hello Blocks %d\n", i.get()); };
39 A *a = new A;
40 a->F();
41 return 0;