[PATCH] D55659: [Sema][ObjC] Disallow non-trivial C struct fields in unions

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 7 10:37:02 PST 2019


rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Two minor tweaks, but otherwise LGTM.



================
Comment at: lib/AST/Type.cpp:2273
+    const RecordDecl *RD = QT->castAs<RecordType>()->getDecl();
+    // C++ classes are ignored.
+    if (isa<CXXRecordDecl>(RD))
----------------
Might be good to spell this out: we don't want to apply the C restriction in C++ because C++ (1) can apply the restriction at a finer grain by banning copying/destroying the union and (2) allows users to override these restrictions by declaring explicit constructors/etc., which we're not proposing to add to C.


================
Comment at: test/SemaObjC/arc-decls.m:24
+
+union  u_trivial_c {
+  volatile int b;
----------------
spacing


Repository:
  rC Clang

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

https://reviews.llvm.org/D55659





More information about the cfe-commits mailing list