summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
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
commit5790d5295e0d6c02ef39b7246085bbcf0d518852 (patch)
treef5f27f231e649a28e8fc061842d17b916da79bb6 /clang/lib/Sema
parentee8155d01a70c14654a83bd21354c77afc9f41a5 (diff)
downloadbcm5719-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.cpp21
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.
OpenPOWER on IntegriCloud