Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o %t -fblocks |
Anders Carlsson | 4de9fce | 2009-03-01 01:09:12 +0000 | [diff] [blame] | 2 | void (^f)(void) = ^{}; |
Anders Carlsson | a17d7cc | 2009-04-08 02:55:55 +0000 | [diff] [blame] | 3 | |
| 4 | // rdar://6768379 |
| 5 | int f0(int (^a0)()) { |
| 6 | return a0(1, 2, 3); |
| 7 | } |
Daniel Dunbar | 0e4f40e | 2009-04-17 00:48:04 +0000 | [diff] [blame] | 8 | |
| 9 | // Verify that attributes on blocks are set correctly. |
| 10 | typedef struct s0 T; |
| 11 | struct s0 { |
| 12 | int a[64]; |
| 13 | }; |
| 14 | |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 15 | // RUN: grep 'internal void @__f2_block_invoke_(.struct.s0\* noalias sret .*, .*, .* byval .*)' %t |
Daniel Dunbar | 0e4f40e | 2009-04-17 00:48:04 +0000 | [diff] [blame] | 16 | struct s0 f2(struct s0 a0) { |
| 17 | return ^(struct s0 a1){ return a1; }(a0); |
| 18 | } |
| 19 | |
Chris Lattner | f1c97eb | 2009-04-21 04:41:23 +0000 | [diff] [blame] | 20 | // This should not crash: rdar://6808051 |
| 21 | void *P = ^{ |
| 22 | void *Q = __func__; |
| 23 | }; |
| 24 | |
Mike Stump | dd2fb9c | 2009-05-01 01:31:57 +0000 | [diff] [blame] | 25 | void (^test1)(void) = ^(void) { |
| 26 | __block int i; |
| 27 | ^ { i = 1; }(); |
| 28 | }; |
Chris Lattner | f1c97eb | 2009-04-21 04:41:23 +0000 | [diff] [blame] | 29 | |