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 | |
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')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 16 |
2 files changed, 22 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c7f37fc2867..dfa1e031779 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1470,8 +1470,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, CheckExtraCXXDefaultArguments(D); if (R.getTypePtr()->isObjCInterfaceType()) { - Diag(D.getIdentifierLoc(), diag::err_statically_allocated_object) - << D.getIdentifier(); + Diag(D.getIdentifierLoc(), diag::err_statically_allocated_object); InvalidDecl = true; } @@ -2761,6 +2760,13 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { << D.getCXXScopeSpec().getRange(); New->setInvalidDecl(); } + // Parameter declarators cannot be interface types. All ObjC objects are + // passed by reference. + if (parmDeclType->isObjCInterfaceType()) { + Diag(D.getIdentifierLoc(), diag::err_object_cannot_be_by_value) + << "passed"; + New->setInvalidDecl(); + } // Add the parameter declaration into this scope. S->AddDecl(New); @@ -3671,8 +3677,7 @@ void Sema::ActOnFields(Scope* S, } /// A field cannot be an Objective-c object if (FDTy->isObjCInterfaceType()) { - Diag(FD->getLocation(), diag::err_statically_allocated_object) - << FD->getDeclName(); + Diag(FD->getLocation(), diag::err_statically_allocated_object); FD->setInvalidDecl(); EnclosingDecl->setInvalidDecl(); continue; 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 |