diff options
author | Eric Fiselier <eric@efcs.ca> | 2017-05-09 22:21:24 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2017-05-09 22:21:24 +0000 |
commit | 87cd035326a39523eeb1b295ad36cff337141ef9 (patch) | |
tree | cb1c41b18e002dab07c5ca51c9416b5c7f39bed8 | |
parent | e2a6f1bc951b6a7bee04ff3decf5117aa42195da (diff) |
[Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member
Summary: This patch implements http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094 which reverts Core 496.
Reviewers: rsmith
Reviewed By: rsmith
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D32984
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302593 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Type.cpp | 7 | ||||
-rw-r--r-- | test/CXX/drs/dr20xx.cpp | 30 | ||||
-rw-r--r-- | test/CXX/drs/dr4xx.cpp | 7 | ||||
-rw-r--r-- | test/SemaCXX/type-traits.cpp | 2 | ||||
-rw-r--r-- | www/cxx_dr_status.html | 4 |
5 files changed, 38 insertions, 12 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index df26233b47..22d52bcd3f 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -2114,18 +2114,15 @@ bool QualType::isTriviallyCopyableType(const ASTContext &Context) const { 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()) diff --git a/test/CXX/drs/dr20xx.cpp b/test/CXX/drs/dr20xx.cpp new file mode 100644 index 0000000000..b97a9a46bc --- /dev/null +++ b/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&), ""); +} diff --git a/test/CXX/drs/dr4xx.cpp b/test/CXX/drs/dr4xx.cpp index 3ea226a745..a55bb91be5 100644 --- a/test/CXX/drs/dr4xx.cpp +++ b/test/CXX/drs/dr4xx.cpp @@ -1202,16 +1202,15 @@ namespace dr495 { // dr495: 3.5 long n2 = s2; } -namespace dr496 { // dr496: no +namespace dr496 { // dr496: sup dr2094 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]; + // This checks the dr2094 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]; } diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp index 9da59b93c5..9191225762 100644 --- a/test/SemaCXX/type-traits.cpp +++ b/test/SemaCXX/type-traits.cpp @@ -1256,7 +1256,7 @@ void is_trivially_copyable2() 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 { diff --git a/www/cxx_dr_status.html b/www/cxx_dr_status.html index a7874b2f12..d852decb50 100644 --- a/www/cxx_dr_status.html +++ b/www/cxx_dr_status.html @@ -3017,7 +3017,7 @@ of class templates</td> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#496">496</a></td> <td>CD3</td> <td>Is a volatile-qualified type really a POD?</td> - <td class="none" align="center">No</td> + <td class="none" align="center">Superseded by <a href="#dr2094">dr2094</a></td> </tr> <tr id="497"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#497">497</a></td> @@ -12379,7 +12379,7 @@ and <I>POD class</I></td> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094">2094</a></td> <td>DR</td> <td>Trivial copy/move constructor for class with volatile member</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Clang 5.0</td> </tr> <tr id="2095"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2095">2095</a></td> |