[Sema] Diagnose default-initialization, destruction, and copying of non-trivial…

Authored by ahatanak on Jul 12 2019, 6:47 PM.


[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.


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

llvm-svn: 365985