blob: 3e59449e0bbbff0b32b11249ed8250725368e7e6 [file] [log] [blame]
Daniel Dunbar1c566672009-02-24 01:43:46 +00001// 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 Jahanianb79e6612008-11-17 18:03:28 +00004
5#include <stdio.h>
6
Fariborz Jahanianf2878e52008-11-21 19:21:53 +00007@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 Jahanianb79e6612008-11-17 18:03:28 +000025void foo(id a) {
26 @synchronized(a) {
27 printf("Swimming? No.");
28 return;
29 }
30}
31
Daniel Dunbar1c566672009-02-24 01:43:46 +000032int f0(id a) {
33 int x = 0;
34 @synchronized((x++, a)) {
35 }
36 return x; // ret i32 1
37}
Fariborz Jahanianf2878e52008-11-21 19:21:53 +000038
Daniel Dunbar1c566672009-02-24 01:43:46 +000039void 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}