On Apr 11, 2012, at 8:29 AM, David Chisnall <[email protected]> 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. > + if (const AtomicType *ToAtomicType = ToType->getAs<AtomicType>()) { > + if (ToAtomicType->getValueType() == FromType) > + return true; > + } This should be using S.Context.hasSameUnqualifiedType rather than ==. It should also happen as the *second* conversion, after a potential lvalue-to-rvalue conversion. Also, this really shouldn't be immediately returning 'true'. Rather, it should just update SCS and FromType and flow through to the end. Finally, should this really be considered an identity conversion? For example, how should this behave? void f(_Atomic(int) x); // #1 void f(int x); // #2 f(3); // ambiguous, or prefers #2? - Doug > // 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) {} > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
