[ObjC] Allow declaring __strong pointer fields in structs in Objective-C
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
diff --git a/clang/test/SemaObjC/arc-decls.m b/clang/test/SemaObjC/arc-decls.m
index 15fb78b..c728f00 100644
--- a/clang/test/SemaObjC/arc-decls.m
+++ b/clang/test/SemaObjC/arc-decls.m
@@ -3,7 +3,7 @@
// rdar://8843524
struct A {
- id x; // expected-error {{ARC forbids Objective-C objects in struct}}
+ id x;
};
union u {
@@ -13,7 +13,7 @@
@interface I {
struct A a;
struct B {
- id y[10][20]; // expected-error {{ARC forbids Objective-C objects in struct}}
+ id y[10][20];
id z;
} b;
@@ -23,7 +23,7 @@
// rdar://10260525
struct r10260525 {
- id (^block) (); // expected-error {{ARC forbids blocks in struct}}
+ id (^block) ();
};
struct S {