aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-11 19:17:25 +0000
committerChris Lattner <sabre@nondot.org>2009-04-11 19:17:25 +0000
commitbb74982f30e295d91c2282a16862d674f88d636a (patch)
tree0bafb53c7b63eb82ce1e74394e6ef0ca8ff61475 /lib/Sema/SemaDecl.cpp
parent2dd979fbd59938babbed76e2376116511b403c93 (diff)
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
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 5fe44d3089..d3f24cae90 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1891,7 +1891,15 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
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;