]> granicus.if.org Git - clang/commitdiff
Don't ICE on missing interface declaration when declaring one of its protocols.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 17 Jan 2008 20:33:24 +0000 (20:33 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 17 Jan 2008 20:33:24 +0000 (20:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46141 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaDeclObjC.cpp
test/Parser/objc-category-neg-1.m [new file with mode: 0644]

index b2e7b7955663b4098ef95118e22e2142a7650be6..5e15753af6f526c31f9819b3d8924b4c6b1e02dc 100644 (file)
@@ -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 (file)
index 0000000..3da911b
--- /dev/null
@@ -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