[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

Nicolas Lesser via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 2 16:06:58 PDT 2018


Rakete1111 added inline comments.


================
Comment at: lib/Sema/SemaDeclCXX.cpp:6174
+      Record->hasAttr<TriviallyRelocatableAttr>() &&
+      !isTemplateInstantiation(Record->getTemplateSpecializationKind())) {
+    if (Record->getDefinition() && !Record->isDependentContext() &&
----------------
The call to `isTemplateInstantiation` is wrong. Consider:

```
template<class T>
struct [[trivially_relocatable]] A {
  T t;
};

struct X {
  X() = default;
  X(X &&) = delete;
};

A<X> d;
static_assert(!__is_trivially_relocatable(decltype(d))); // oops, fires
```

There is also no diagnostic saying that `A<X>` cannot be marked `[[trivially_relocatable]]`.


================
Comment at: lib/Sema/SemaDeclCXX.cpp:6176
+    if (Record->getDefinition() && !Record->isDependentContext() &&
+        !Record->isBeingDefined()) {
+      // Check that the destructor is non-deleted.
----------------
`Record` is never being defined at this point, even for templates. It also always has a definition AFAIK.


Repository:
  rC Clang

https://reviews.llvm.org/D50119





More information about the cfe-commits mailing list