[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
Wed Jul 10 15:19:18 PDT 2019


ahatanak marked 3 inline comments as done.
ahatanak added inline comments.


================
Comment at: lib/Sema/SemaExpr.cpp:6097
+      // non-trivial to copy or default-initialize.
+      checkNonTrivialCUnionInInitList(ILE);
+  }
----------------
rjmccall wrote:
> Can we extract a common function that checks the initializer expression of a non-trivial C union?  I think there are at least three separate places that do that in this patch, and it's not too hard to imagine that we might want to add more cases to the common analysis.
Do you mean we should have something like `bool checkNonTrivialCUnionInInitList(const Expr *Init)` so that we don't have to call `dyn_cast`? If `Init` is an `InitListExpr`, the function diagnoses non-trivial C unions types and returns true, otherwise it returns false.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63753/new/

https://reviews.llvm.org/D63753





More information about the cfe-commits mailing list