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: http://review.tizen.org/git/?a=commitdiff_plain;h=3087a2b949d7e952c1aecfd6579b40908380851b;p=platform%2Fupstream%2Fllvm.git 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. llvm-svn: 224902 --- diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index d3a1fa8..1e692eb 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/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/clang/test/CodeGenCXX/atomicinit.cpp b/clang/test/CodeGenCXX/atomicinit.cpp index 91b990b..982396e 100644 --- a/clang/test/CodeGenCXX/atomicinit.cpp +++ b/clang/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