xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjC/objc-read-weak-byref.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// REQUIRES: x86-registered-target,x86-64-registered-target
2*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -S %s -o %t-64.s
3*f4a2713aSLionel Sambuc// RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.s %s
4*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -S %s -o %t-32.s
5*f4a2713aSLionel Sambuc// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s
6*f4a2713aSLionel Sambuc
7*f4a2713aSLionel Sambuc@interface NSObject
8*f4a2713aSLionel Sambuc- copy;
9*f4a2713aSLionel Sambuc@end
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambucint main() {
12*f4a2713aSLionel Sambuc    NSObject *object = 0;
13*f4a2713aSLionel Sambuc    __weak __block NSObject* weak_object = object;
14*f4a2713aSLionel Sambuc    void (^callback) (void) = [^{
15*f4a2713aSLionel Sambuc        if (weak_object)
16*f4a2713aSLionel Sambuc                [weak_object copy];
17*f4a2713aSLionel Sambuc    } copy];
18*f4a2713aSLionel Sambuc    callback();
19*f4a2713aSLionel Sambuc    return 0;
20*f4a2713aSLionel Sambuc}
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc// CHECK-LP64: callq    _objc_read_weak
23*f4a2713aSLionel Sambuc// CHECK-LP64: callq    _objc_read_weak
24*f4a2713aSLionel Sambuc
25*f4a2713aSLionel Sambuc// CHECK-LP32: calll     L_objc_read_weak
26*f4a2713aSLionel Sambuc// CHECK-LP32: calll     L_objc_read_weak
27