diff options
| author | Jordan Rose <jordan_rose@apple.com> | 2014-08-12 16:20:36 +0000 |
|---|---|---|
| committer | Jordan Rose <jordan_rose@apple.com> | 2014-08-12 16:20:36 +0000 |
| commit | 5790d5295e0d6c02ef39b7246085bbcf0d518852 (patch) | |
| tree | f5f27f231e649a28e8fc061842d17b916da79bb6 /clang/lib/Sema | |
| parent | ee8155d01a70c14654a83bd21354c77afc9f41a5 (diff) | |
| download | bcm5719-llvm-5790d5295e0d6c02ef39b7246085bbcf0d518852.tar.gz bcm5719-llvm-5790d5295e0d6c02ef39b7246085bbcf0d518852.zip | |
Allow @synchronized to contextually convert a C++ object to an ObjC object pointer.
Patch by Grant Paul!
llvm-svn: 215453
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 6bb71eb8958..12e0ef7fa6c 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/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. |

