<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Dec 28, 2014 at 1:47 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Sun Dec 28 15:47:31 2014<br>
New Revision: 224902<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=224902&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=224902&view=rev</a><br>
Log:<br>
Sema: Permit an atomic type to be initialized by the same atomic type<br>
<br>
We forgot a conversion step when initializing an atomic type with an<br>
rvalue of the same type.<br>
<br>
This fixes PR22043.<br>
<br>
Modified:<br>
cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
cfe/trunk/test/CodeGenCXX/atomicinit.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=224902&r1=224901&r2=224902&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=224902&r1=224901&r2=224902&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun Dec 28 15:47:31 2014<br>
@@ -2759,7 +2759,11 @@ Sema::PerformImplicitConversion(Expr *Fr<br>
// Perform the first implicit conversion.<br>
switch (SCS.First) {<br>
case ICK_Identity:<br>
- // Nothing to do.<br>
+ if (const AtomicType *FromAtomic = FromType->getAs<AtomicType>()) {<br>
+ FromType = FromAtomic->getValueType().getUnqualifiedType();<br>
+ From = ImplicitCastExpr::Create(Context, FromType, CK_AtomicToNonAtomic,<br>
+ From, /*BasePath=*/nullptr, VK_RValue);<br>
+ }<br>
break;<br>
<br>
case ICK_Lvalue_To_Rvalue: {<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/atomicinit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/atomicinit.cpp?rev=224902&r1=224901&r2=224902&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/atomicinit.cpp?rev=224902&r1=224901&r2=224902&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/atomicinit.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/atomicinit.cpp Sun Dec 28 15:47:31 2014<br>
@@ -1,5 +1,9 @@<br>
// RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 -std=c++11 | FileCheck %s<br>
<br>
+// CHECK-DAG: @PR22043 = global i32 0, align 4<br>
+typedef _Atomic(int) AtomicInt;<br>
+AtomicInt PR22043 = AtomicInt();<br></blockquote><div><br></div><div>As far as I can tell from the C standard, it should not be possible for an rvalue to have an atomic-qualified type. That being the case, I think the right fix here is for the type of 'AtomicInt()' to be merely 'int', just as the type of 'ConstInt()' is 'int' in</div><div><br></div><div> typedef const int ConstInt;</div><div> ConstInt blah = ConstInt();</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
// CHECK-DAG: @_ZN7PR180978constant1aE = global { i16, i8 } { i16 1, i8 6 }, align 4<br>
// CHECK-DAG: @_ZN7PR180978constant1bE = global { i16, i8 } { i16 2, i8 6 }, align 4<br>
// CHECK-DAG: @_ZN7PR180978constant1cE = global { i16, i8 } { i16 3, i8 6 }, align 4<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>