]> granicus.if.org Git - clang/commit
[Sema] Diagnose default-initialization, destruction, and copying of
authorAkira Hatanaka <ahatanaka@apple.com>
Sat, 13 Jul 2019 01:47:15 +0000 (01:47 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Sat, 13 Jul 2019 01:47:15 +0000 (01:47 +0000)
commit657b099cc209b4c70658e8cbc1e29e40b7dbffe7
tree1c79967bb90719a1d22e9b8ee2b957570bc15364
parentdd578bb497322855a0116d2ed3b6ccff7f8ad7db
[Sema] Diagnose default-initialization, destruction, and copying of
non-trivial C union types

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@365985 91177308-0d34-0410-b5e6-96231b3b80d8
17 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/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]