]> granicus.if.org Git - clang/commitdiff
volatile types are not trivially copyable.
authorEli Friedman <eli.friedman@gmail.com>
Wed, 11 Sep 2013 03:49:34 +0000 (03:49 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Wed, 11 Sep 2013 03:49:34 +0000 (03:49 +0000)
PR17123.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190484 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Type.cpp
lib/Sema/SemaChecking.cpp
test/SemaCXX/type-traits.cpp

index 8027f52216fcbfe99efb14d8b6c8fc7329c53209..7421bae7bf5435537e9f1af14bcbca4ae81de3aa 100644 (file)
@@ -1097,15 +1097,18 @@ bool QualType::isTriviallyCopyableType(ASTContext &Context) const {
     }        
   }
 
-  // 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())
index 82eca73e8c20b36ae30cd545bd1b0f204dac594f..cba5ffe5fa43d64a649a9fe78a9f7a54857436fe 100644 (file)
@@ -1038,7 +1038,8 @@ ExprResult Sema::SemaAtomicOpsOverloaded(ExprResult TheCallResult,
     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)
index f9e679187dea5e6d68297fa1f70be7e6f203f3ec..1dc215625c2a2db8b689f03a6c98b1259ab5beac 100644 (file)
@@ -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 {