r224322 - Sema: Don't crash converting to bool from _Atomic
David Majnemer
david.majnemer at gmail.com
Mon Dec 15 22:31:17 PST 2014
Author: majnemer
Date: Tue Dec 16 00:31:17 2014
New Revision: 224322
URL: http://llvm.org/viewvc/llvm-project?rev=224322&view=rev
Log:
Sema: Don't crash converting to bool from _Atomic
Turning our _Atomic L-value into an R-value removes its _Atomic-ness.
However, we didn't update our 'FromType' which made
ScalarTypeToBooleanCastKind think we were trying to pass it a
non-scalar.
This fixes PR21836.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/atomic-type.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=224322&r1=224321&r2=224322&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Dec 16 00:31:17 2014
@@ -2754,10 +2754,10 @@ Sema::PerformImplicitConversion(Expr *Fr
case ICK_Lvalue_To_Rvalue: {
assert(From->getObjectKind() != OK_ObjCProperty);
- FromType = FromType.getUnqualifiedType();
ExprResult FromRes = DefaultLvalueConversion(From);
assert(!FromRes.isInvalid() && "Can't perform deduced conversion?!");
From = FromRes.get();
+ FromType = From->getType();
break;
}
Modified: cfe/trunk/test/SemaCXX/atomic-type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/atomic-type.cpp?rev=224322&r1=224321&r2=224322&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/atomic-type.cpp (original)
+++ cfe/trunk/test/SemaCXX/atomic-type.cpp Tue Dec 16 00:31:17 2014
@@ -83,3 +83,7 @@ namespace copy_init {
// allows extraneous braces around initializers.
Y y3 = { { X(0) }, { 4 } }; // expected-error 2{{illegal initializer type}}
}
+
+bool PR21836(_Atomic(int) *x) {
+ return *x;
+}
More information about the cfe-commits
mailing list