summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2014-08-12 16:20:36 +0000
committerJordan Rose <jordan_rose@apple.com>2014-08-12 16:20:36 +0000
commit17735d72a8292df453ee5d2910997e6a3248f7f3 (patch)
treee24fd8f244e33a95ab51b6abcb5c6ea977f614cc /lib/Sema/SemaStmt.cpp
parentb452261a386b680c459f36489a2dc8ede2e8f889 (diff)
Allow @synchronized to contextually convert a C++ object to an ObjC object pointer.
Patch by Grant Paul! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215453 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 6bb71eb895..12e0ef7fa6 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -3102,9 +3102,24 @@ Sema::ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand) {
if (!type->isDependentType() &&
!type->isObjCObjectPointerType()) {
const PointerType *pointerType = type->getAs<PointerType>();
- if (!pointerType || !pointerType->getPointeeType()->isVoidType())
- return Diag(atLoc, diag::error_objc_synchronized_expects_object)
- << type << operand->getSourceRange();
+ if (!pointerType || !pointerType->getPointeeType()->isVoidType()) {
+ if (getLangOpts().CPlusPlus) {
+ if (RequireCompleteType(atLoc, type,
+ diag::err_incomplete_receiver_type))
+ return Diag(atLoc, diag::error_objc_synchronized_expects_object)
+ << type << operand->getSourceRange();
+
+ ExprResult result = PerformContextuallyConvertToObjCPointer(operand);
+ if (!result.isUsable())
+ return Diag(atLoc, diag::error_objc_synchronized_expects_object)
+ << type << operand->getSourceRange();
+
+ operand = result.get();
+ } else {
+ return Diag(atLoc, diag::error_objc_synchronized_expects_object)
+ << type << operand->getSourceRange();
+ }
+ }
}
// The operand to @synchronized is a full-expression.