summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclObjC.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 967094af773..660f745228b 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -1344,9 +1344,17 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration(
}
QualType resultDeclType;
- if (ReturnType)
+ if (ReturnType) {
resultDeclType = QualType::getFromOpaquePtr(ReturnType);
- else // get the type for "id".
+
+ // Methods cannot return interface types. All ObjC objects are
+ // passed by reference.
+ if (resultDeclType->isObjCInterfaceType()) {
+ Diag(MethodLoc, diag::err_object_cannot_be_by_value)
+ << "returned";
+ return 0;
+ }
+ } else // get the type for "id".
resultDeclType = Context.getObjCIdType();
ObjCMethodDecl* ObjCMethod =
@@ -1375,7 +1383,9 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration(
argType = Context.getPointerType(argType);
else if (argType->isObjCInterfaceType()) {
// FIXME! provide more precise location for the parameter
- Diag(MethodLoc, diag::err_object_as_method_param);
+ Diag(MethodLoc, diag::err_object_cannot_be_by_value)
+ << "passed";
+ ObjCMethod->setInvalidDecl();
return 0;
}
} else
OpenPOWER on IntegriCloud