[cfe-commits] r46358 - in /cfe/trunk: Sema/SemaExprObjC.cpp include/clang/Basic/DiagnosticKinds.def test/Sema/objc-bad-receiver-1.m
Fariborz Jahanian
fjahanian at apple.com
Fri Jan 25 09:43:39 PST 2008
Author: fjahanian
Date: Fri Jan 25 11:43:39 2008
New Revision: 46358
URL: http://llvm.org/viewvc/llvm-project?rev=46358&view=rev
Log:
Diagnose bad receiver type.
Added:
cfe/trunk/test/Sema/objc-bad-receiver-1.m
Modified:
cfe/trunk/Sema/SemaExprObjC.cpp
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
Modified: cfe/trunk/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExprObjC.cpp?rev=46358&r1=46357&r2=46358&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/Sema/SemaExprObjC.cpp Fri Jan 25 11:43:39 2008
@@ -258,8 +258,10 @@
SourceRange(lbrac, rbrac));
}
else {
- assert(ObjCInterfaceType::classof(receiverType.getTypePtr()) &&
- "bad receiver type");
+ if (!isa<ObjCInterfaceType>(receiverType.getTypePtr())) {
+ Diag(lbrac, diag::error_bad_receiver_type, receiverType.getAsString());
+ return true;
+ }
ClassDecl = static_cast<ObjCInterfaceType*>(
receiverType.getTypePtr())->getDecl();
// FIXME: consider using InstanceMethodPool, since it will be faster
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=46358&r1=46357&r2=46358&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Fri Jan 25 11:43:39 2008
@@ -482,6 +482,8 @@
"Only one element declaration is allowed")
DIAG(warn_expected_implementation, WARNING,
"@end must appear in an @implementation context")
+DIAG(error_bad_receiver_type, ERROR,
+ "bad receiver type (its type is '%0')")
//===----------------------------------------------------------------------===//
// Semantic Analysis
Added: cfe/trunk/test/Sema/objc-bad-receiver-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-bad-receiver-1.m?rev=46358&view=auto
==============================================================================
--- cfe/trunk/test/Sema/objc-bad-receiver-1.m (added)
+++ cfe/trunk/test/Sema/objc-bad-receiver-1.m Fri Jan 25 11:43:39 2008
@@ -0,0 +1,9 @@
+// RUN: clang -fsyntax-only -verify %s
+
+ at interface I
+- (id) retain;
+ at end
+
+void __raiseExc1() {
+ [objc_lookUpClass("NSString") retain]; // expected-error {{ "bad receiver type (its type is 'int')" }}
+}
More information about the cfe-commits
mailing list