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;
return bar6(objectCreationBlock); // expected-warning{{incompatible block pointer types passing 'id (^)()', expected 'id (^)(int)'}}
}
-void foo67(id (^x)(int)) {
+void foo7(id (^x)(int)) {
if (x) { }
}
+
+@interface itf
+@end
+
+void foo8() {
+ ^(itf x) {};
+}
}
@end
-Super foo(Super parm1) { // expected-error{{Objective-C interface type 'Super' cannot be passed by value}}
+Super foo( // expected-error{{Objective-C interface type 'Super' cannot be returned by value}}
+ Super parm1) { // expected-error{{Objective-C interface type 'Super' cannot be passed by value}}
Super p1; // expected-error{{Objective-C type cannot be statically allocated}}
return p1;
}
@end
void somefunc(foo x) {} // expected-error {{Objective-C interface type 'foo' cannot be passed by value}}
+foo somefunc2() {} // expected-error {{Objective-C interface type 'foo' cannot be returned by value}}