]> granicus.if.org Git - clang/commit
[Sema][ObjC] Disallow non-trivial C struct fields in unions.
authorAkira Hatanaka <ahatanaka@apple.com>
Thu, 7 Feb 2019 20:21:46 +0000 (20:21 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Thu, 7 Feb 2019 20:21:46 +0000 (20:21 +0000)
commit444a6050b21250608abb14d157df25d8a4425209
tree6a9473899f24a4c205fe98a991558e8838709383
parentcb6ec6f91389339f7ad93ad53714cf221105b556
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353459 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/Type.h
include/clang/Basic/DiagnosticSemaKinds.td
lib/AST/Type.cpp
lib/Sema/SemaDecl.cpp
test/SemaObjC/arc-decls.m