[PATCH] D46112: Allow _Atomic to be specified on incomplete types
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun May 6 12:34:03 PDT 2018
aaron.ballman added inline comments.
================
Comment at: lib/Sema/SemaType.cpp:8022
+ else if (LangOpts.CPlusPlus && isCompleteType(Loc, T) &&
+ !T.isTriviallyCopyableType(Context))
// Some other non-trivially-copyable type (probably a C++ class)
----------------
rsmith wrote:
> efriedma wrote:
> > If you're going to allow incomplete types in C++, you'll need some code to handle the case where the type is initially incomplete, but completed later.
> Perhaps the trivially-copyable requirement could be deferred in all cases until we reach an actual load or store. Constraints that are only enforced when a type happens to be complete are generally a bad idea (we have a mess like this for constraints on types being non-abstract, and we're still working on unsticking ourselves from that mess in the C++ standard).
>
> In passing, I'd also note that we need the trivially-copyable requirement even outside C++, for structs containing `__weak` / `__strong` fields.
I'm not quite certain I've properly captured the request here, but I took a stab at it. One thing to note is that our behavior for type checking `__atomic_load()` appears to diverge from GCC with regards to trivial copyability, even before my patch.
https://godbolt.org/g/g2fqLK
https://reviews.llvm.org/D46112
More information about the cfe-commits
mailing list