diagnose attempts to return objc interfaces by-value from C functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68873 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 5fe44d3..d3f24ca 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1891,7 +1891,15 @@
R->getAsFunctionType()->getResultType(),
diag::err_abstract_type_in_decl,
AbstractReturnType))
- InvalidDecl = true;
+ InvalidDecl = true;
+
+ // Do not allow returning a objc interface by-value.
+ if (R->getAsFunctionType()->getResultType()->isObjCInterfaceType()) {
+ Diag(D.getIdentifierLoc(),
+ diag::err_object_cannot_be_passed_returned_by_value) << 0
+ << R->getAsFunctionType()->getResultType();
+ InvalidDecl = true;
+ }
bool isVirtualOkay = false;
FunctionDecl *NewFD;