ARC mode. Declaring __strong pointer fields in structs was not allowed in Objective-C ARC until now because that would make the struct non-trivial to default-initialize, copy/move, and destroy, which is not something C was designed to do. This patch lifts that restriction. Special functions for non-trivial C structs are synthesized that are needed to default-initialize, copy/move, and destroy the structs and manage the ownership of the objects the __strong pointer fields point to. Non-trivial structs passed to functions are destructed in the callee function. rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D41228 llvm-svn: 326307
29 lines
853 B
Objective-C
29 lines
853 B
Objective-C
// RUN: %clang_cc1 -E %s -fobjc-arc "-triple" "x86_64-apple-macosx10.7.0" -fobjc-runtime-has-weak | FileCheck --check-prefix=CHECK-ARC %s
|
|
// RUN: %clang_cc1 -E %s -fobjc-arc "-triple" "x86_64-apple-macosx10.6.0" | FileCheck --check-prefix=CHECK-ARCLITE %s
|
|
|
|
#if __has_feature(objc_arc)
|
|
void has_objc_arc_feature();
|
|
#else
|
|
void no_objc_arc_feature();
|
|
#endif
|
|
|
|
#if __has_feature(objc_arc_weak)
|
|
void has_objc_arc_weak_feature();
|
|
#else
|
|
void no_objc_arc_weak_feature();
|
|
#endif
|
|
|
|
#if __has_feature(objc_arc_fields)
|
|
void has_objc_arc_fields();
|
|
#else
|
|
void no_objc_arc_fields();
|
|
#endif
|
|
|
|
// CHECK-ARC: void has_objc_arc_feature();
|
|
// CHECK-ARC: void has_objc_arc_weak_feature();
|
|
// CHECK-ARC: void has_objc_arc_fields();
|
|
|
|
// CHECK-ARCLITE: void has_objc_arc_feature();
|
|
// CHECK-ARCLITE: void no_objc_arc_weak_feature();
|
|
// CHECK-ARCLITE: void has_objc_arc_fields();
|