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

Chandler Carruth chandlerc at google.com
Wed Apr 11 08:46:44 PDT 2012


On Wed, Apr 11, 2012 at 4:29 PM, David Chisnall <csdavec at swan.ac.uk> wrote:

> 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.
>

It seems like this should get an ext-warn...

+  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
>

Is there not an existing test for _Atomic as used in C++ that this could be
folded into?


> @@ -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) {}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120411/f9866ca3/attachment.html>


More information about the cfe-commits mailing list