[cfe-commits] r154499 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/CodeGenCXX/atomicinit.cpp

David Chisnall csdavec at swan.ac.uk
Wed Apr 11 08:29:15 PDT 2012


Author: theraven
Date: Wed Apr 11 10:29:15 2012
New Revision: 154499

URL: http://llvm.org/viewvc/llvm-project?rev=154499&view=rev
Log:
Allow c++ initialisers to initialise _Atomic fields.


Added:
    cfe/trunk/test/CodeGenCXX/atomicinit.cpp
Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=154499&r1=154498&r2=154499&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 11 10:29:15 2012
@@ -1316,6 +1316,13 @@
   SCS.setFromType(FromType);
   SCS.CopyConstructor = 0;
 
+  // Allow conversion to _Atomic types.  These are C11 and are provided as an
+  // extension in C++ mode.  
+  if (const AtomicType *ToAtomicType = ToType->getAs<AtomicType>()) {
+    if (ToAtomicType->getValueType() == FromType)
+      return true;
+  }
+
   // There are no standard conversions for class types in C++, so
   // abort early. When overloading in C, however, we do permit
   if (FromType->isRecordType() || ToType->isRecordType()) {

Added: cfe/trunk/test/CodeGenCXX/atomicinit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/atomicinit.cpp?rev=154499&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/atomicinit.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/atomicinit.cpp Wed Apr 11 10:29:15 2012
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | FileCheck %s
+struct A {
+  _Atomic(int) i;
+  A(int j);
+  void v(int j);
+};
+// Storing to atomic values should be atomic
+// CHECK: store atomic i32
+void A::v(int j) { i = j; }
+// Initialising atomic values should not be atomic
+// CHECK-NOT: store atomic 
+A::A(int j) : i(j) {}





More information about the cfe-commits mailing list