diff options
| author | Steve Naroff <snaroff@apple.com> | 2009-02-20 22:59:16 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2009-02-20 22:59:16 +0000 |
| commit | 326064168a28884d635d9f93a5104cdbdf5a67cb (patch) | |
| tree | e0df97804aa610b00af33f903d08b907f4c8398d /clang/lib/Sema/SemaDeclObjC.cpp | |
| parent | e739d191560f4af07290a94d24ddf171d38ba0e0 (diff) | |
| download | bcm5719-llvm-326064168a28884d635d9f93a5104cdbdf5a67cb.tar.gz bcm5719-llvm-326064168a28884d635d9f93a5104cdbdf5a67cb.zip | |
Fix <rdar://problem/6500554> missing objc error message.
llvm-svn: 65198
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 16 |
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 |

