From e4fb82839a762e632f63e195058015e2f1ca27a8 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 22 Jan 2010 23:04:44 +0000 Subject: [PATCH] outside a method, 'super' should resolve in a normal name look up to mimic gcc's behavior. Fixes radar 7400691. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94246 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprObjC.cpp | 12 +++++++++++- test/SemaObjC/super.m | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 85889fa5d6..ea8f4e3e89 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -398,7 +398,17 @@ Sema::ExprResult Sema::ActOnClassMessage( return ActOnInstanceMessage(ReceiverExpr.get(), Sel, lbrac, selectorLoc, rbrac, Args, NumArgs); } - return Diag(receiverLoc, diag::err_undeclared_var_use) << receiverName; + else if (TypedefDecl *OCTD = dyn_cast_or_null(SuperDecl)) { + const ObjCInterfaceType *OCIT; + OCIT = OCTD->getUnderlyingType()->getAs(); + if (!OCIT) { + Diag(receiverLoc, diag::err_invalid_receiver_to_message); + return true; + } + ClassDecl = OCIT->getDecl(); + } + else + return Diag(receiverLoc, diag::err_undeclared_var_use) << receiverName; } } else ClassDecl = getObjCInterfaceDecl(receiverName, receiverLoc); diff --git a/test/SemaObjC/super.m b/test/SemaObjC/super.m index 3b8697288a..a61d72fda5 100644 --- a/test/SemaObjC/super.m +++ b/test/SemaObjC/super.m @@ -39,3 +39,10 @@ void f0(int super) { void f1(int puper) { [super m]; // expected-error{{use of undeclared identifier 'super'}} } + +// radar 7400691 +typedef Foo super; + +void test() { + [super cMethod]; +}