From: Fariborz Jahanian Date: Thu, 17 Jan 2008 20:33:24 +0000 (+0000) Subject: Don't ICE on missing interface declaration when declaring one of its protocols. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c453b3ded5dc9bff05e6e66eb725a0938303d73;p=clang Don't ICE on missing interface declaration when declaring one of its protocols. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46141 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Sema/SemaDeclObjC.cpp b/Sema/SemaDeclObjC.cpp index b2e7b79556..5e15753af6 100644 --- a/Sema/SemaDeclObjC.cpp +++ b/Sema/SemaDeclObjC.cpp @@ -275,26 +275,27 @@ Sema::DeclTy *Sema::ActOnStartCategoryInterface( SourceLocation EndProtoLoc) { ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName); - /// Check that class of this category is already completely declared. - if (!IDecl || IDecl->isForwardDecl()) { - Diag(ClassLoc, diag::err_undef_interface, ClassName->getName()); - return 0; - } ObjCCategoryDecl *CDecl = new ObjCCategoryDecl(AtInterfaceLoc, NumProtoRefs, CategoryName); CDecl->setClassInterface(IDecl); - /// Check for duplicate interface declaration for this category - ObjCCategoryDecl *CDeclChain; - for (CDeclChain = IDecl->getCategoryList(); CDeclChain; - CDeclChain = CDeclChain->getNextClassCategory()) { - if (CDeclChain->getIdentifier() == CategoryName) { - Diag(CategoryLoc, diag::err_dup_category_def, ClassName->getName(), - CategoryName->getName()); - break; + + /// Check that class of this category is already completely declared. + if (!IDecl || IDecl->isForwardDecl()) + Diag(ClassLoc, diag::err_undef_interface, ClassName->getName()); + else { + /// Check for duplicate interface declaration for this category + ObjCCategoryDecl *CDeclChain; + for (CDeclChain = IDecl->getCategoryList(); CDeclChain; + CDeclChain = CDeclChain->getNextClassCategory()) { + if (CDeclChain->getIdentifier() == CategoryName) { + Diag(CategoryLoc, diag::err_dup_category_def, ClassName->getName(), + CategoryName->getName()); + break; + } } - } if (!CDeclChain) CDecl->insertNextClassCategory(); + } if (NumProtoRefs) { /// Check then save referenced protocols diff --git a/test/Parser/objc-category-neg-1.m b/test/Parser/objc-category-neg-1.m new file mode 100644 index 0000000000..3da911b6de --- /dev/null +++ b/test/Parser/objc-category-neg-1.m @@ -0,0 +1,8 @@ +// RUN: clang -fsyntax-only -verify %s + +void __assert_rtn(const char *, const char *, int, const char *) __attribute__((__noreturn__)); +static __inline__ int __inline_isfinitef (float ) __attribute__ ((always_inline)); + +@interface NSATSTypesetter (NSPantherCompatibility) // expected-error {{ "cannot find interface declaration for 'NSATSTypesetter'" }} +- (id)lineFragmentRectForProposedRect:(id)proposedRect remainingRect:(id)remainingRect __attribute__((deprecated)); +@end