[cfe-commits] r66185 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/super-property-notation.m
Steve Naroff
snaroff at apple.com
Thu Mar 5 12:12:01 PST 2009
Author: snaroff
Date: Thu Mar 5 14:12:00 2009
New Revision: 66185
URL: http://llvm.org/viewvc/llvm-project?rev=66185&view=rev
Log:
Partial fix <rdar://problem/6301205> [irgen] dot-syntax on super isn't supported.
Tweak Sema::ActOnMemberReferenceExpr() and Sema::ActOnDeclarationNameExpr() to handle "super." notation for Class methods.
Added:
cfe/trunk/test/SemaObjC/super-property-notation.m
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=66185&r1=66184&r2=66185&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Mar 5 14:12:00 2009
@@ -673,8 +673,13 @@
}
// Needed to implement property "super.method" notation.
if (D == 0 && II->isStr("super")) {
- QualType T = Context.getPointerType(Context.getObjCInterfaceType(
- getCurMethodDecl()->getClassInterface()));
+ QualType T;
+
+ if (getCurMethodDecl()->isInstanceMethod())
+ T = Context.getPointerType(Context.getObjCInterfaceType(
+ getCurMethodDecl()->getClassInterface()));
+ else
+ T = Context.getObjCClassType();
return Owned(new (Context) ObjCSuperExpr(Loc, T));
}
}
@@ -1956,6 +1961,24 @@
return ExprError(Diag(MemberLoc, diag::err_property_not_found)
<< &Member << BaseType);
}
+ // Handle properties on ObjC 'Class' types.
+ if (OpKind == tok::period && (BaseType == Context.getObjCClassType())) {
+ // Also must look for a getter name which uses property syntax.
+ Selector Sel = PP.getSelectorTable().getNullarySelector(&Member);
+ if (ObjCMethodDecl *MD = getCurMethodDecl()) {
+ ObjCMethodDecl *OMD;
+ // FIXME: need to also look locally in the implementation.
+ if ((OMD = MD->getClassInterface()->lookupClassMethod(Sel))) {
+ // Check the use of this method.
+ if (DiagnoseUseOfDecl(OMD, MemberLoc))
+ return ExprError();
+
+ return Owned(new (Context) ObjCMessageExpr(BaseExpr, Sel,
+ OMD->getResultType(), OMD, OpLoc, MemberLoc, NULL, 0));
+ }
+ }
+ }
+
// Handle 'field access' to vectors, such as 'V.xx'.
if (BaseType->isExtVectorType()) {
QualType ret = CheckExtVectorComponent(BaseType, OpLoc, Member, MemberLoc);
Added: cfe/trunk/test/SemaObjC/super-property-notation.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/super-property-notation.m?rev=66185&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/super-property-notation.m (added)
+++ cfe/trunk/test/SemaObjC/super-property-notation.m Thu Mar 5 14:12:00 2009
@@ -0,0 +1,30 @@
+// RUN: clang -fsyntax-only -verify %s
+
+ at interface B
++(int) classGetter;
+-(int) getter;
+ at end
+
+ at interface A : B
+ at end
+
+ at implementation A
++(int) classGetter {
+ return 0;
+}
+
++(int) classGetter2 {
+ return super.classGetter;
+}
+
+-(void) method {
+ int x = super.getter;
+}
+ at end
+
+void f0() {
+ // FIXME: not implemented yet.
+ //int l1 = A.classGetter;
+ int l2 = [A classGetter2];
+}
+
More information about the cfe-commits
mailing list