]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/6450964> clang on xcode: Assertion failed: (RecordForDecl &&...
authorSteve Naroff <snaroff@apple.com>
Wed, 17 Dec 2008 14:13:49 +0000 (14:13 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 17 Dec 2008 14:13:49 +0000 (14:13 +0000)
This was a recent regression caused by r61043 (related to code gen. for ivar references).

Fariborz, please review. I have some other concerns related to code generation for ivars that we can discuss later.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61134 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclObjC.cpp
test/SemaObjC/interface-layout-2.m [new file with mode: 0644]

index 9e803b71e164c790fcb59e852dd7efecf9e8a75e..12c224501c646603e6483c493280e7c22da7aacf 100644 (file)
@@ -369,6 +369,8 @@ void ObjCInterfaceDecl::addInstanceVariablesToClass(ObjCIvarDecl **ivars,
 ///
 FieldDecl *ObjCInterfaceDecl::lookupFieldDeclForIvar(ASTContext &Context, 
                                                      const ObjCIvarDecl *ivar) {
+  if (!RecordForDecl)
+    addRecordToClass(Context);
   assert(RecordForDecl && "lookupFieldDeclForIvar no storage for class");
   DeclarationName Member = ivar->getDeclName();
   DeclContext::lookup_result Lookup = RecordForDecl->lookup(Context, Member);
diff --git a/test/SemaObjC/interface-layout-2.m b/test/SemaObjC/interface-layout-2.m
new file mode 100644 (file)
index 0000000..50dd2f9
--- /dev/null
@@ -0,0 +1,16 @@
+// RUN: clang %s -fsyntax-only -verify
+@interface A
+{
+  int ivar;
+}
+@end
+
+@interface B : A
+- (int)ivar;
+@end
+
+@implementation B
+- (int)ivar {
+  return ivar;
+} 
+@end