Diagnose bad receiver type.

llvm-svn: 46358
This commit is contained in:
Fariborz Jahanian 2008-01-25 17:43:39 +00:00
parent e5433a90ce
commit cc9c5452d1
3 changed files with 15 additions and 2 deletions

View File

@ -258,8 +258,10 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
SourceRange(lbrac, rbrac)); SourceRange(lbrac, rbrac));
} }
else { else {
assert(ObjCInterfaceType::classof(receiverType.getTypePtr()) && if (!isa<ObjCInterfaceType>(receiverType.getTypePtr())) {
"bad receiver type"); Diag(lbrac, diag::error_bad_receiver_type, receiverType.getAsString());
return true;
}
ClassDecl = static_cast<ObjCInterfaceType*>( ClassDecl = static_cast<ObjCInterfaceType*>(
receiverType.getTypePtr())->getDecl(); receiverType.getTypePtr())->getDecl();
// FIXME: consider using InstanceMethodPool, since it will be faster // FIXME: consider using InstanceMethodPool, since it will be faster

View File

@ -482,6 +482,8 @@ DIAG(err_toomany_element_decls, ERROR,
"Only one element declaration is allowed") "Only one element declaration is allowed")
DIAG(warn_expected_implementation, WARNING, DIAG(warn_expected_implementation, WARNING,
"@end must appear in an @implementation context") "@end must appear in an @implementation context")
DIAG(error_bad_receiver_type, ERROR,
"bad receiver type (its type is '%0')")
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Semantic Analysis // Semantic Analysis

View File

@ -0,0 +1,9 @@
// RUN: clang -fsyntax-only -verify %s
@interface I
- (id) retain;
@end
void __raiseExc1() {
[objc_lookUpClass("NSString") retain]; // expected-error {{ "bad receiver type (its type is 'int')" }}
}