Fix trivial crasher and downgrade an error to warning (to match GCC).

llvm-svn: 51976
This commit is contained in:
Steve Naroff 2008-06-05 04:33:44 +00:00
parent cfdf6166fc
commit d1c3d1130b
3 changed files with 25 additions and 7 deletions

View File

@ -425,7 +425,7 @@ DIAG(err_duplicate_protocol_def, ERROR,
"duplicate protocol declaration of '%0'")
DIAG(err_undef_interface, ERROR,
"cannot find interface declaration for '%0'")
DIAG(err_dup_category_def, ERROR,
DIAG(warn_dup_category_def, WARNING,
"duplicate interface declaration for category '%0(%1)'")
DIAG(warn_undef_interface, WARNING,
"cannot find interface declaration for '%0'")

View File

@ -406,13 +406,13 @@ Sema::DeclTy *Sema::ActOnStartCategoryInterface(
/// Check that class of this category is already completely declared.
if (!IDecl || IDecl->isForwardDecl())
Diag(ClassLoc, diag::err_undef_interface, ClassName->getName());
else {
else if (CategoryName) {
/// 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(),
Diag(CategoryLoc, diag::warn_dup_category_def, ClassName->getName(),
CategoryName->getName());
break;
}

View File

@ -7,7 +7,7 @@
@interface MyClass1 (Category1) <p1> // expected-warning {{cannot find protocol definition for 'p1', referenced by 'Category1'}}
@end
@interface MyClass1 (Category1) // expected-error {{duplicate interface declaration for category 'MyClass1(Category1)'}}
@interface MyClass1 (Category1) // expected-warning {{duplicate interface declaration for category 'MyClass1(Category1)'}}
@end
@interface MyClass1 (Category3)
@ -20,9 +20,9 @@
@interface MyClass1 (Category8) @end
@interface MyClass1 (Category4) @end // expected-error {{duplicate interface declaration for category 'MyClass1(Category4)'}}
@interface MyClass1 (Category7) @end // expected-error {{duplicate interface declaration for category 'MyClass1(Category7)'}}
@interface MyClass1 (Category8) @end // expected-error {{duplicate interface declaration for category 'MyClass1(Category8)'}}
@interface MyClass1 (Category4) @end // expected-warning {{duplicate interface declaration for category 'MyClass1(Category4)'}}
@interface MyClass1 (Category7) @end // expected-warning {{duplicate interface declaration for category 'MyClass1(Category7)'}}
@interface MyClass1 (Category8) @end // expected-warning {{duplicate interface declaration for category 'MyClass1(Category8)'}}
@protocol p3 @end
@ -35,4 +35,22 @@
@interface MyClass2 (Category) @end // expected-error {{cannot find interface declaration for 'MyClass2'}}
@interface XCRemoteComputerManager
@end
@interface XCRemoteComputerManager()
@end
@interface XCRemoteComputerManager()
@end
@interface XCRemoteComputerManager(x)
@end
@interface XCRemoteComputerManager(x) // expected-warning {{duplicate interface declaration for category 'XCRemoteComputerManager(x)'}}
@end
@implementation XCRemoteComputerManager
@end