Daniel Dunbar | 1c56667 | 2009-02-24 01:43:46 +0000 | [diff] [blame^] | 1 | // RUN: clang -emit-llvm -triple=i686-apple-darwin8 -o %t %s -O2 && |
| 2 | // RUN: grep 'ret i32' %t | count 1 && |
| 3 | // RUN: grep 'ret i32 1' %t | count 1 |
Fariborz Jahanian | b79e661 | 2008-11-17 18:03:28 +0000 | [diff] [blame] | 4 | |
| 5 | #include <stdio.h> |
| 6 | |
Fariborz Jahanian | f2878e5 | 2008-11-21 19:21:53 +0000 | [diff] [blame] | 7 | @interface MyClass |
| 8 | { |
| 9 | } |
| 10 | - (void)method; |
| 11 | @end |
| 12 | |
| 13 | @implementation MyClass |
| 14 | |
| 15 | - (void)method |
| 16 | { |
| 17 | @synchronized(self) |
| 18 | { |
| 19 | NSLog(@"sync"); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | @end |
| 24 | |
Fariborz Jahanian | b79e661 | 2008-11-17 18:03:28 +0000 | [diff] [blame] | 25 | void foo(id a) { |
| 26 | @synchronized(a) { |
| 27 | printf("Swimming? No."); |
| 28 | return; |
| 29 | } |
| 30 | } |
| 31 | |
Daniel Dunbar | 1c56667 | 2009-02-24 01:43:46 +0000 | [diff] [blame^] | 32 | int f0(id a) { |
| 33 | int x = 0; |
| 34 | @synchronized((x++, a)) { |
| 35 | } |
| 36 | return x; // ret i32 1 |
| 37 | } |
Fariborz Jahanian | f2878e5 | 2008-11-21 19:21:53 +0000 | [diff] [blame] | 38 | |
Daniel Dunbar | 1c56667 | 2009-02-24 01:43:46 +0000 | [diff] [blame^] | 39 | void f1(id a) { |
| 40 | // The trick here is that the return shouldn't go through clean up, |
| 41 | // but there isn't a simple way to check this property. |
| 42 | @synchronized(({ return; }), a) { |
| 43 | return; |
| 44 | } |
| 45 | } |