[PATCH] D63753: [Sema] Instead of rejecting C unions with non-trivial fields, detect attempts to destruct/initialize/copy them.
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 25 00:00:44 PDT 2019
ahatanak created this revision.
ahatanak added reviewers: rjmccall, rsmith.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.
This patch diagnoses uses of non-trivial C unions in the following contexts:
- function parameters
- function returns
- variables with automatic storage duration
- assignment
- compound literal with automatic storage duration
- block capture except when a `__block` variable is captured by a non-escaping block
Note that we already reject non-trivial C structs/unions used for variable function arguments. Also this patch doesn't detect non-trivial C unions passed to functions without function prototypes. I think that's okay since clang will reject the function definition's parameters, but if it isn't okay, it's possible to add diagnostics for that too.
See the discussion in https://reviews.llvm.org/D62988 for more background.
rdar://problem/50679094
Repository:
rC Clang
https://reviews.llvm.org/D63753
Files:
include/clang/AST/Type.h
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Sema/Sema.h
lib/AST/Type.cpp
lib/Sema/Sema.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaType.cpp
test/CodeGenObjC/Inputs/strong_in_union.h
test/CodeGenObjC/strong-in-c-struct.m
test/SemaObjC/arc-decls.m
test/SemaObjC/non-trivial-c-union.m
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63753.206368.patch
Type: text/x-patch
Size: 37271 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190625/9ca711a7/attachment-0001.bin>
More information about the cfe-commits
mailing list