[cfe-commits] r149653 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprObjC.cpp test/SemaObjC/receiver-forward-class.m
Fariborz Jahanian
fjahanian at apple.com
Thu Feb 2 17:02:44 PST 2012
Author: fjahanian
Date: Thu Feb 2 19:02:44 2012
New Revision: 149653
URL: http://llvm.org/viewvc/llvm-project?rev=149653&view=rev
Log:
objc: Issue diagnostic when receiver type is a forward class declaration and
it is treated as of 'id' type resulting in multiple method lookup.
// rdar://10686120
Added:
cfe/trunk/test/SemaObjC/receiver-forward-class.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExprObjC.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=149653&r1=149652&r2=149653&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Feb 2 19:02:44 2012
@@ -417,6 +417,8 @@
"class implementation is declared here">;
def note_class_declared : Note<
"class is declared here">;
+def note_receiver_is_id : Note<
+ "receiver is treated with 'id' type for purpose of method lookup">;
def note_suppressed_class_declare : Note<
"class with specified objc_requires_property_definitions attribute is declared here">;
def warn_dup_category_def : Warning<
@@ -3268,6 +3270,9 @@
"no visible @interface for %0 declares the selector %1">;
def err_arc_receiver_forward_instance : Error<
"receiver type %0 for instance message is a forward declaration">;
+def warn_receiver_forward_instance : Warning<
+ "receiver type %0 for instance message is a forward declaration">,
+ InGroup<DiagGroup<"receiver-forward-class">>, DefaultIgnore;
def err_arc_collection_forward : Error<
"collection expression type %0 is a forward declaration">;
def err_arc_multiple_method_decl : Error<
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=149653&r1=149652&r2=149653&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu Feb 2 19:02:44 2012
@@ -1380,11 +1380,15 @@
? PDiag(diag::err_arc_receiver_forward_instance)
<< (Receiver ? Receiver->getSourceRange()
: SourceRange(SuperLoc))
- : PDiag())) {
+ : PDiag(diag::warn_receiver_forward_instance)
+ << (Receiver ? Receiver->getSourceRange()
+ : SourceRange(SuperLoc)))) {
if (getLangOptions().ObjCAutoRefCount)
return ExprError();
forwardClass = OCIType->getInterfaceDecl();
+ Diag(Receiver ? Receiver->getLocStart()
+ : SuperLoc, diag::note_receiver_is_id);
Method = 0;
} else {
Method = ClassDecl->lookupInstanceMethod(Sel);
Added: cfe/trunk/test/SemaObjC/receiver-forward-class.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/receiver-forward-class.m?rev=149653&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/receiver-forward-class.m (added)
+++ cfe/trunk/test/SemaObjC/receiver-forward-class.m Thu Feb 2 19:02:44 2012
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -Wreceiver-forward-class -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -Wreceiver-forward-class -verify %s
+// rdar://10686120
+
+ at class A; // expected-note {{forward declaration of class here}}
+
+ at interface B
+-(int) width; // expected-note {{using}}
+ at end
+ at interface C
+-(float) width; // expected-note {{also found}}
+ at end
+
+int f0(A *x) {
+ return [x width]; // expected-warning {{receiver type 'A' for instance message is a forward declaration}} \
+ // expected-warning {{multiple methods named 'width' found}} \
+ // expected-note {{receiver is treated with 'id' type for purpose of method lookup}}
+}
+
More information about the cfe-commits
mailing list