[cfe-commits] r46141 - in /cfe/trunk: Sema/SemaDeclObjC.cpp test/Parser/objc-category-neg-1.m

Fariborz Jahanian fjahanian at apple.com
Thu Jan 17 12:33:25 PST 2008


Author: fjahanian
Date: Thu Jan 17 14:33:24 2008
New Revision: 46141

URL: http://llvm.org/viewvc/llvm-project?rev=46141&view=rev
Log:
Don't ICE on missing interface declaration when declaring one of its protocols.


Added:
    cfe/trunk/test/Parser/objc-category-neg-1.m
Modified:
    cfe/trunk/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDeclObjC.cpp?rev=46141&r1=46140&r2=46141&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/Sema/SemaDeclObjC.cpp Thu Jan 17 14:33:24 2008
@@ -275,26 +275,27 @@
                       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

Added: cfe/trunk/test/Parser/objc-category-neg-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-category-neg-1.m?rev=46141&view=auto

==============================================================================
--- cfe/trunk/test/Parser/objc-category-neg-1.m (added)
+++ cfe/trunk/test/Parser/objc-category-neg-1.m Thu Jan 17 14:33:24 2008
@@ -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));
+
+ at interface NSATSTypesetter (NSPantherCompatibility) // expected-error {{ "cannot find interface declaration for 'NSATSTypesetter'" }}
+- (id)lineFragmentRectForProposedRect:(id)proposedRect remainingRect:(id)remainingRect __attribute__((deprecated));
+ at end





More information about the cfe-commits mailing list