]> granicus.if.org Git - clang/commit
[Sema] Diagnose default-initialization, destruction, and copying of
authorAkira Hatanaka <ahatanaka@apple.com>
Sat, 7 Sep 2019 00:34:43 +0000 (00:34 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Sat, 7 Sep 2019 00:34:43 +0000 (00:34 +0000)
commitad203f89e5e8cd0c764ac490a8848c65651485cd
treefbe5bafb4b6eff17dcf9db2e31c9d6950e37d3ff
parenta2d3035e5b81fcae4472ba02c8c7a7f9cc675d3c
[Sema] Diagnose default-initialization, destruction, and copying of
non-trivial C union types

This recommits r365985, which was reverted because it broke a few
projects using unions containing non-trivial ObjC pointer fields in
system headers. We now have a patch to fix the problem (see
https://reviews.llvm.org/D65256).

Original commit message:

This patch diagnoses uses of non-trivial C unions and structs/unions
containing non-trivial C unions in the following contexts, which require
default-initialization, destruction, or copying of the union objects,
instead of disallowing fields of non-trivial types in C unions, which is
what we currently do:

- function parameters.
- function returns.
- assignments.
- compound literals.
- block captures except capturing of `__block` variables by non-escaping blocks.
- local and global variable definitions.
- lvalue-to-rvalue conversions of volatile types.

See the discussion in https://reviews.llvm.org/D62988 for more background.

rdar://problem/50679094

Differential Revision: https://reviews.llvm.org/D63753

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371275 91177308-0d34-0410-b5e6-96231b3b80d8
18 files changed:
include/clang/AST/Decl.h
include/clang/AST/DeclBase.h
include/clang/AST/Type.h
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Sema/Sema.h
lib/AST/Decl.cpp
lib/AST/Type.cpp
lib/Sema/Sema.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaType.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp
test/CodeGenObjC/Inputs/strong_in_union.h [deleted file]
test/CodeGenObjC/strong-in-c-struct.m
test/PCH/non-trivial-c-union.m [new file with mode: 0644]
test/SemaObjC/arc-decls.m
test/SemaObjC/non-trivial-c-union.m [new file with mode: 0644]