[cfe-commits] r96676 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/SemaObjCXX/message.mm
Douglas Gregor
dgregor at apple.com
Fri Feb 19 07:18:45 PST 2010
Author: dgregor
Date: Fri Feb 19 09:18:45 2010
New Revision: 96676
URL: http://llvm.org/viewvc/llvm-project?rev=96676&view=rev
Log:
Make Sema::ActOnClassMessage robust when name lookup for the receiver
name finds something other than a TypedefDecl or an
ObjCInterfaceDecl. This is a small part of <rdar://problem/7660386>.
Added:
cfe/trunk/test/SemaObjCXX/message.mm
Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=96676&r1=96675&r2=96676&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Fri Feb 19 09:18:45 2010
@@ -426,14 +426,14 @@
if (!ClassDecl) {
NamedDecl *IDecl
= LookupSingleName(TUScope, receiverName, LookupOrdinaryName);
- if (TypedefDecl *OCTD = dyn_cast_or_null<TypedefDecl>(IDecl)) {
- const ObjCInterfaceType *OCIT;
- OCIT = OCTD->getUnderlyingType()->getAs<ObjCInterfaceType>();
- if (!OCIT) {
- Diag(receiverLoc, diag::err_invalid_receiver_to_message);
- return true;
- }
- ClassDecl = OCIT->getDecl();
+ if (TypedefDecl *OCTD = dyn_cast_or_null<TypedefDecl>(IDecl))
+ if (const ObjCInterfaceType *OCIT
+ = OCTD->getUnderlyingType()->getAs<ObjCInterfaceType>())
+ ClassDecl = OCIT->getDecl();
+
+ if (!ClassDecl) {
+ Diag(receiverLoc, diag::err_invalid_receiver_to_message);
+ return true;
}
}
assert(ClassDecl && "missing interface declaration");
Added: cfe/trunk/test/SemaObjCXX/message.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/message.mm?rev=96676&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjCXX/message.mm (added)
+++ cfe/trunk/test/SemaObjCXX/message.mm Fri Feb 19 09:18:45 2010
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+ at interface I1
+- (void)method;
+ at end
+
+ at implementation I1
+- (void)method {
+ struct x { };
+ [x method]; // expected-error{{invalid receiver to message expression}}
+}
+ at end
More information about the cfe-commits
mailing list