diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index b7810da98e72..c5f689fe4930 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -824,6 +824,8 @@ FunctionDecl *Sema::getCurFunctionDecl() { ObjCMethodDecl *Sema::getCurMethodDecl() { DeclContext *DC = getFunctionLevelDeclContext(); + while (isa(DC)) + DC = DC->getParent(); return dyn_cast(DC); } diff --git a/clang/test/SemaObjC/ivar-lookup.m b/clang/test/SemaObjC/ivar-lookup.m index df9d8bac9077..a8620caf21ed 100644 --- a/clang/test/SemaObjC/ivar-lookup.m +++ b/clang/test/SemaObjC/ivar-lookup.m @@ -80,3 +80,34 @@ extern struct foo x; int IVAR; // expected-error {{instance variable is already declared}} } @end + +// PR5984 +// rdar://14037151 +@interface Radar14037151 { + int myStatus; +} +- (int) test; +@end + +@implementation Radar14037151 +- (int) test +{ + myStatus = 1; // works + __typeof(myStatus) __in; // works. + union U { + __typeof(myStatus) __in; // fails. + }; + struct S { + __typeof(myStatus) __in; // fails. + struct S1 { + __typeof(myStatus) __in; // fails. + struct S { + __typeof(myStatus) __in; // fails. + }; + }; + }; + + return 0; +} +@end +