xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/cp-blocks-linetables.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fblocks -g -emit-llvm %s -o - | FileCheck %s
2*f4a2713aSLionel Sambuc // Ensure that we generate a line table entry for the block cleanup.
3*f4a2713aSLionel Sambuc // CHECK: define {{.*}} @__main_block_invoke
4*f4a2713aSLionel Sambuc // CHECK: _NSConcreteStackBlock
5*f4a2713aSLionel Sambuc // CHECK: = bitcast {{.*}}, !dbg ![[L1:[0-9]+]]
6*f4a2713aSLionel Sambuc // CHECK-NOT:  call {{.*}} @_Block_object_dispose{{.*}}, !dbg ![[L1]]
7*f4a2713aSLionel Sambuc // CHECK: ret
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc void * _NSConcreteStackBlock;
10*f4a2713aSLionel Sambuc #ifdef __cplusplus
11*f4a2713aSLionel Sambuc extern "C" void exit(int);
12*f4a2713aSLionel Sambuc #else
13*f4a2713aSLionel Sambuc extern void exit(int);
14*f4a2713aSLionel Sambuc #endif
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc enum numbers {
17*f4a2713aSLionel Sambuc   zero, one, two, three, four
18*f4a2713aSLionel Sambuc };
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc typedef enum numbers (^myblock)(enum numbers);
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc 
test(myblock I)23*f4a2713aSLionel Sambuc double test(myblock I) {
24*f4a2713aSLionel Sambuc   return I(three);
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc 
main()27*f4a2713aSLionel Sambuc int main() {
28*f4a2713aSLionel Sambuc   __block enum numbers x = one;
29*f4a2713aSLionel Sambuc   __block enum numbers y = two;
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc   /* Breakpoint for first Block function.  */
32*f4a2713aSLionel Sambuc   myblock CL = ^(enum numbers z)
33*f4a2713aSLionel Sambuc     { enum numbers savex = x;
34*f4a2713aSLionel Sambuc       { __block enum numbers x = savex;
35*f4a2713aSLionel Sambuc 	y = z;
36*f4a2713aSLionel Sambuc 	if (y != three)
37*f4a2713aSLionel Sambuc 	  exit (6);
38*f4a2713aSLionel Sambuc 	test (
39*f4a2713aSLionel Sambuc 	      /* Breakpoint for second Block function.  */
40*f4a2713aSLionel Sambuc 	      ^ (enum numbers z) {
41*f4a2713aSLionel Sambuc 		if (y != three) {
42*f4a2713aSLionel Sambuc 		  exit(1);
43*f4a2713aSLionel Sambuc 		}
44*f4a2713aSLionel Sambuc 		if (x != one)
45*f4a2713aSLionel Sambuc 		  exit(2);
46*f4a2713aSLionel Sambuc 		x = z;
47*f4a2713aSLionel Sambuc 		if (x != three)
48*f4a2713aSLionel Sambuc 		  exit(3);
49*f4a2713aSLionel Sambuc 		if (y != three)
50*f4a2713aSLionel Sambuc 		  exit(4);
51*f4a2713aSLionel Sambuc 		return (enum numbers) four;
52*f4a2713aSLionel Sambuc 	      });}
53*f4a2713aSLionel Sambuc       return x;
54*f4a2713aSLionel Sambuc     };
55*f4a2713aSLionel Sambuc 
56*f4a2713aSLionel Sambuc   enum numbers res = (enum numbers)test(CL);
57*f4a2713aSLionel Sambuc 
58*f4a2713aSLionel Sambuc   if (res != one)
59*f4a2713aSLionel Sambuc     exit (5);
60*f4a2713aSLionel Sambuc   return 0;
61*f4a2713aSLionel Sambuc }
62