aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-05-08 23:45:49 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-05-08 23:45:49 +0000
commit9f8f026fc1cd1aa2942a2850a037398415128f8a (patch)
tree4915d602b759924635cacf8cc8ce18e568d3d495
parent484c7cad9bf5caefd3b0912aa778457fd46c2804 (diff)
We want to diagnose sending message to a forward class
and we also want to tell which message is actually being sent. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71296 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td1
-rw-r--r--lib/Sema/SemaExprObjC.cpp5
-rw-r--r--test/Analysis/rdar-6540084.m2
-rw-r--r--test/SemaObjC/forward-class-receiver.m2
4 files changed, 6 insertions, 4 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index f491a43e3b..577392cbd6 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1692,6 +1692,7 @@ def err_collection_expr_type : Error<
def ext_invalid_sign_spec : Extension<"'%0' cannot be signed or unsigned">;
def warn_receiver_forward_class : Warning<
"receiver %0 is a forward class and corresponding @interface may not exist">;
+def note_method_sent_forward_class : Note<"method %0 is used for the forward class">;
def warn_missing_declspec : Warning<
"declaration specifier missing, defaulting to 'int'">;
def warn_missing_type_specifier : Warning<
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 3dbc2cf015..de6b69f90f 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -424,10 +424,11 @@ Sema::ExprResult Sema::ActOnClassMessage(
QualType returnType;
if (ClassDecl->isForwardDecl()) {
// A forward class used in messaging is tread as a 'Class'
+ Diag(lbrac, diag::warn_receiver_forward_class) << ClassDecl->getDeclName();
Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(lbrac,rbrac));
if (Method)
- Diag(lbrac, diag::warn_receiver_forward_class)
- << ClassDecl->getDeclName();
+ Diag(Method->getLocation(), diag::note_method_sent_forward_class)
+ << Method->getDeclName();
}
if (!Method)
Method = ClassDecl->lookupClassMethod(Context, Sel);
diff --git a/test/Analysis/rdar-6540084.m b/test/Analysis/rdar-6540084.m
index c788543bf3..18ab038f6e 100644
--- a/test/Analysis/rdar-6540084.m
+++ b/test/Analysis/rdar-6540084.m
@@ -22,7 +22,7 @@ typedef struct {} TazVersion;
@implementation FooBazController
- (NSArray *)excitingStuff:(FooBaz *)options {
BugsBunnyType matchType = options.matchType;
- NSPredicate *isSearchablePredicate = [NSPredicate predicateWithFormat:@"isSearchable == YES"]; // expected-warning{{return type defaults to 'id'}}
+ NSPredicate *isSearchablePredicate = [NSPredicate predicateWithFormat:@"isSearchable == YES"]; // expected-warning{{receiver 'NSPredicate' is a forward class and corresponding}} // expected-warning{{return type defaults to 'id'}}
for (TazGuttenberg *Guttenberg in options.papyrus) {
NSArray *GuttenbergNodes = [Guttenberg nodes]; // expected-warning{{return type defaults to 'id'}}
NSArray *searchableNodes = [GuttenbergNodes filteredArrayUsingPredicate:isSearchablePredicate]; // expected-warning{{return type defaults to 'id'}}
diff --git a/test/SemaObjC/forward-class-receiver.m b/test/SemaObjC/forward-class-receiver.m
index 8353f39d38..ebba0fd896 100644
--- a/test/SemaObjC/forward-class-receiver.m
+++ b/test/SemaObjC/forward-class-receiver.m
@@ -1,7 +1,7 @@
// RUN: clang-cc -fsyntax-only -verify %s
@interface I
-+ new;
++ new; // expected-note {{method 'new' is used for the forward class}}
@end
Class isa;