[PATCH] D63753: [Sema] Instead of rejecting C unions with non-trivial fields, detect attempts to destruct/initialize/copy them.

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 27 23:46:22 PDT 2019


rjmccall added inline comments.


================
Comment at: include/clang/Sema/Sema.h:2124
+    // Implicitly initialized subobject.
+    NTCUC_ImplicitInitSubObject,
+    // Uninialized variable with automatic storage duration.
----------------
"default-initialized", please.


================
Comment at: lib/Sema/SemaExpr.cpp:16218
+    checkNonTrivialCUnion(E->getType(), E->getExprLoc(),
+                          Sema::NTCUC_LValueToRValueVolatile);
+
----------------
It looks like you're generally warning about this based on the specific context that forced an lvalue-to-rvalue conversion.  I'm not sure `volatile` is special except that we actually perform the load even in unused-value contexts.  Is the assumption that you've exhaustively covered all the other contexts of lvalue-to-rvalue conversions whose values will actually be used?  That seems questionable to me.


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