summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2019-02-07 20:21:46 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2019-02-07 20:21:46 +0000
commit5fbdccd834874aad04e21b0253084a27013a3f81 (patch)
tree4710b8a956fff71b5c1b2acd718ce52187297103 /clang/test
parentfe3ac70b18ea2b614545734542944acf2f97bfcf (diff)
downloadbcm5719-llvm-5fbdccd834874aad04e21b0253084a27013a3f81.tar.gz
bcm5719-llvm-5fbdccd834874aad04e21b0253084a27013a3f81.zip
[Sema][ObjC] Disallow non-trivial C struct fields in unions.
This patch fixes a bug where clang doesn’t reject union fields of non-trivial C struct types. For example: ``` // This struct is non-trivial under ARC. struct S0 { id x; }; union U0 { struct S0 s0; // clang should reject this. struct S0 s1; // clang should reject this. }; void test(union U0 a) { // Previously, both 'a.s0.x' and 'a.s1.x' were released in this // function. } ``` rdar://problem/46677858 Differential Revision: https://reviews.llvm.org/D55659 llvm-svn: 353459
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaObjC/arc-decls.m18
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/test/SemaObjC/arc-decls.m b/clang/test/SemaObjC/arc-decls.m
index c728f00c7e5..0abd45dac33 100644
--- a/clang/test/SemaObjC/arc-decls.m
+++ b/clang/test/SemaObjC/arc-decls.m
@@ -3,13 +3,29 @@
// rdar://8843524
struct A {
- id x;
+ id x[4];
+ id y;
};
union u {
id u; // expected-error {{ARC forbids Objective-C objects in union}}
};
+union u_nontrivial_c {
+ struct A a; // expected-error {{non-trivial C types are disallowed in union}}
+};
+
+// Volatile fields are fine.
+struct C {
+ volatile int x[4];
+ volatile int y;
+};
+
+union u_trivial_c {
+ volatile int b;
+ struct C c;
+};
+
@interface I {
struct A a;
struct B {
OpenPOWER on IntegriCloud