[PATCH] D62988: Add an attribute to allow fields of non-trivial types in C unions
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 6 15:45:42 PDT 2019
ahatanak created this revision.
ahatanak added a reviewer: rjmccall.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.
clang currently disallows fields of non-trivial types (e.g., `__strong`) in unions in C mode since it's not possible for the compiler to determine how the unions should be initialized, destructed, or copied.
This patch adds support for a new attribute `non_trivial_union_member`, which causes fields annotated with the attribute to be trivial when computing the trivialness of the containing union. This means the users are responsible for patching up the code so that the union is initialized, destructed, and copied in a functionally correct way.
rdar://problem/50591731
Repository:
rC Clang
https://reviews.llvm.org/D62988
Files:
include/clang/AST/Decl.h
include/clang/Basic/Attr.td
include/clang/Basic/AttrDocs.td
lib/AST/Decl.cpp
lib/AST/Type.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp
test/CodeGenObjC/strong-in-c-struct.m
test/SemaObjC/attr-non-trivial-union-member.m
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62988.203459.patch
Type: text/x-patch
Size: 8483 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190606/edf18204/attachment-0001.bin>
More information about the cfe-commits
mailing list