forked from OSchip/llvm-project
Allow c++ initialisers to initialise _Atomic fields.
llvm-svn: 154499
This commit is contained in:
parent
2335a5cb85
commit
28397be059
|
@ -1316,6 +1316,13 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
|
|||
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()) {
|
||||
|
|
|
@ -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) {}
|
Loading…
Reference in New Issue