[PATCH] D32984: [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 8 16:17:32 PDT 2017


EricWF updated this revision to Diff 98229.
EricWF added a comment.

- Use `sup` instead of `reverted by` to match style of other DRs.


https://reviews.llvm.org/D32984

Files:
  lib/AST/Type.cpp
  test/CXX/drs/dr20xx.cpp
  test/CXX/drs/dr4xx.cpp
  test/SemaCXX/type-traits.cpp


Index: test/SemaCXX/type-traits.cpp
===================================================================
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1256,7 +1256,7 @@
   int t33[F(__is_trivially_copyable(ExtDefaulted))];
 
   int t34[T(__is_trivially_copyable(const int))];
-  int t35[F(__is_trivially_copyable(volatile int))];
+  int t35[T(__is_trivially_copyable(volatile int))];
 }
 
 struct CStruct {
Index: test/CXX/drs/dr4xx.cpp
===================================================================
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -1202,16 +1202,15 @@
   long n2 = s2;
 }
 
-namespace dr496 { // dr496: no
+namespace dr496 { // dr496: sup dr2095 in 5.0
   struct A { int n; };
   struct B { volatile int n; };
   int check1[ __is_trivially_copyable(const int) ? 1 : -1];
-  int check2[!__is_trivially_copyable(volatile int) ? 1 : -1];
+  // FIXME: This checks the dr2095 behavior, not dr496
+  int check2[ __is_trivially_copyable(volatile int) ? 1 : -1];
   int check3[ __is_trivially_constructible(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check4[ __is_trivially_constructible(B, const B&) ? 1 : -1];
   int check5[ __is_trivially_assignable(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1];
 }
 
Index: test/CXX/drs/dr20xx.cpp
===================================================================
--- /dev/null
+++ test/CXX/drs/dr20xx.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors \
+// RUN:            -Wno-variadic-macros -Wno-c11-extensions
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+
+// expected-no-diagnostics
+
+#if __cplusplus < 201103L
+#define static_assert(...) _Static_assert(__VA_ARGS__)
+#endif
+
+namespace dr2094 { // dr2094: 5.0
+  struct A { int n; };
+  struct B { volatile int n; };
+  static_assert(__is_trivially_copyable(volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int[]), "");
+  static_assert(__is_trivially_copyable(A), "");
+  static_assert(__is_trivially_copyable(volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A[]), "");
+  static_assert(__is_trivially_copyable(B), "");
+
+  static_assert(__is_trivially_constructible(A, A const&), "");
+  static_assert(__is_trivially_constructible(B, B const&), "");
+
+  static_assert(__is_trivially_assignable(A, const A&), "");
+  static_assert(__is_trivially_assignable(B, const B&), "");
+}
Index: lib/AST/Type.cpp
===================================================================
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2114,18 +2114,15 @@
   if (hasNonTrivialObjCLifetime())
     return false;
 
-  // C++11 [basic.types]p9
+  // C++11 [basic.types]p9 - See Core 2094
   //   Scalar types, trivially copyable class types, arrays of such types, and
-  //   non-volatile const-qualified versions of these types are collectively
+  //   cv-qualified versions of these types are collectively
   //   called trivially copyable types.
 
   QualType CanonicalType = getCanonicalType();
   if (CanonicalType->isDependentType())
     return false;
 
-  if (CanonicalType.isVolatileQualified())
-    return false;
-
   // Return false for incomplete types after skipping any incomplete array types
   // which are expressly allowed by the standard and thus our API.
   if (CanonicalType->isIncompleteType())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32984.98229.patch
Type: text/x-patch
Size: 3920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170508/110b7d0b/attachment.bin>


More information about the cfe-commits mailing list