r190484 - volatile types are not trivially copyable.

Eli Friedman eli.friedman at gmail.com
Tue Sep 10 20:49:35 PDT 2013


Author: efriedma
Date: Tue Sep 10 22:49:34 2013
New Revision: 190484

URL: http://llvm.org/viewvc/llvm-project?rev=190484&view=rev
Log:
volatile types are not trivially copyable.

PR17123.

Modified:
    cfe/trunk/lib/AST/Type.cpp
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/SemaCXX/type-traits.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=190484&r1=190483&r2=190484&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Sep 10 22:49:34 2013
@@ -1097,15 +1097,18 @@ bool QualType::isTriviallyCopyableType(A
     }        
   }
 
-  // C++0x [basic.types]p9
+  // C++11 [basic.types]p9
   //   Scalar types, trivially copyable class types, arrays of such types, and
-  //   cv-qualified versions of these types are collectively called trivial
-  //   types.
+  //   non-volatile const-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())

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=190484&r1=190483&r2=190484&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Sep 10 22:49:34 2013
@@ -1038,7 +1038,8 @@ ExprResult Sema::SemaAtomicOpsOverloaded
     return ExprError();
   }
 
-  if (!IsC11 && !AtomTy.isTriviallyCopyableType(Context)) {
+  if (!IsC11 && !AtomTy.isTriviallyCopyableType(Context) &&
+      !AtomTy->isScalarType()) {
     // For GNU atomics, require a trivially-copyable type. This is not part of
     // the GNU atomics specification, but we enforce it for sanity.
     Diag(DRE->getLocStart(), diag::err_atomic_op_needs_trivial_copy)

Modified: cfe/trunk/test/SemaCXX/type-traits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-traits.cpp?rev=190484&r1=190483&r2=190484&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/type-traits.cpp (original)
+++ cfe/trunk/test/SemaCXX/type-traits.cpp Tue Sep 10 22:49:34 2013
@@ -1072,6 +1072,9 @@ void is_trivially_copyable2()
   int t31[F(__is_trivially_copyable(SuperNonTrivialStruct))];
   int t32[F(__is_trivially_copyable(NonTCStruct))];
   int t33[F(__is_trivially_copyable(ExtDefaulted))];
+
+  int t34[T(__is_trivially_copyable(const int))];
+  int t35[F(__is_trivially_copyable(volatile int))];
 }
 
 struct CStruct {





More information about the cfe-commits mailing list