From: David Majnemer Date: Sun, 28 Dec 2014 21:47:31 +0000 (+0000) Subject: Sema: Permit an atomic type to be initialized by the same atomic type X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8fbf839d6c28ee53ff2eb4d59b16381c66a5a074;p=clang Sema: Permit an atomic type to be initialized by the same atomic type We forgot a conversion step when initializing an atomic type with an rvalue of the same type. This fixes PR22043. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224902 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index d3a1fa8e80..1e692ebe25 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -2759,7 +2759,11 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, // Perform the first implicit conversion. switch (SCS.First) { case ICK_Identity: - // Nothing to do. + if (const AtomicType *FromAtomic = FromType->getAs()) { + FromType = FromAtomic->getValueType().getUnqualifiedType(); + From = ImplicitCastExpr::Create(Context, FromType, CK_AtomicToNonAtomic, + From, /*BasePath=*/nullptr, VK_RValue); + } break; case ICK_Lvalue_To_Rvalue: { diff --git a/test/CodeGenCXX/atomicinit.cpp b/test/CodeGenCXX/atomicinit.cpp index 91b990b70d..982396e177 100644 --- a/test/CodeGenCXX/atomicinit.cpp +++ b/test/CodeGenCXX/atomicinit.cpp @@ -1,5 +1,9 @@ // RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 -std=c++11 | FileCheck %s +// CHECK-DAG: @PR22043 = global i32 0, align 4 +typedef _Atomic(int) AtomicInt; +AtomicInt PR22043 = AtomicInt(); + // CHECK-DAG: @_ZN7PR180978constant1aE = global { i16, i8 } { i16 1, i8 6 }, align 4 // CHECK-DAG: @_ZN7PR180978constant1bE = global { i16, i8 } { i16 2, i8 6 }, align 4 // CHECK-DAG: @_ZN7PR180978constant1cE = global { i16, i8 } { i16 3, i8 6 }, align 4