r183048 - Objective-C: Fixes an ivar lookup bug where

Fariborz Jahanian fjahanian at apple.com
Fri May 31 14:51:13 PDT 2013


Author: fjahanian
Date: Fri May 31 16:51:12 2013
New Revision: 183048

URL: http://llvm.org/viewvc/llvm-project?rev=183048&view=rev
Log:
Objective-C: Fixes an ivar lookup bug where
'ivar' was used inside a record/union used 
as argument to __typeof. // rdar14037151 pr5984

Modified:
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/test/SemaObjC/ivar-lookup.m

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=183048&r1=183047&r2=183048&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Fri May 31 16:51:12 2013
@@ -824,6 +824,8 @@ FunctionDecl *Sema::getCurFunctionDecl()
 
 ObjCMethodDecl *Sema::getCurMethodDecl() {
   DeclContext *DC = getFunctionLevelDeclContext();
+  while (isa<RecordDecl>(DC))
+    DC = DC->getParent();
   return dyn_cast<ObjCMethodDecl>(DC);
 }
 

Modified: cfe/trunk/test/SemaObjC/ivar-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/ivar-lookup.m?rev=183048&r1=183047&r2=183048&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/ivar-lookup.m (original)
+++ cfe/trunk/test/SemaObjC/ivar-lookup.m Fri May 31 16:51:12 2013
@@ -80,3 +80,34 @@ extern struct foo x;
   int IVAR; // expected-error {{instance variable is already declared}}
 }
 @end
+
+// PR5984
+// rdar://14037151
+ at interface Radar14037151 {
+  int myStatus;
+}
+- (int) test;
+ at end
+
+ at 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;
+}
+ at end
+





More information about the cfe-commits mailing list