Diagnose implementation of a property declared in a category

in its class implementation instead of crashing. Fixes radar 7350345.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85813 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Fariborz Jahanian 2009-11-02 18:45:36 +00:00
Родитель cf3293eaeb
Коммит 3684bd4c95
3 изменённых файлов: 31 добавлений и 0 удалений

Просмотреть файл

@ -271,6 +271,11 @@ def error_missing_property_context : Error<
"missing context for property implementation declaration">;
def error_bad_property_decl : Error<
"property implementation must have its declaration in interface %0">;
def error_category_property : Error<
"property declared in category %0 cannot be implemented in "
"class implementation">;
def note_category_property : Note<
"property declared here">;
def error_synthesize_category_decl : Error<
"@synthesize not allowed in a category's implementation">;
def error_missing_property_interface : Error<

Просмотреть файл

@ -2047,6 +2047,14 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
Diag(PropertyLoc, diag::error_bad_property_decl) << IDecl->getDeclName();
return DeclPtrTy();
}
if (const ObjCCategoryDecl *CD =
dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) {
if (CD->getIdentifier()) {
Diag(PropertyLoc, diag::error_category_property) << CD->getDeclName();
Diag(property->getLocation(), diag::note_category_property);
return DeclPtrTy();
}
}
} else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) {
if (Synthesize) {
Diag(AtLoc, diag::error_synthesize_category_decl);

Просмотреть файл

@ -0,0 +1,18 @@
// RUN: clang-cc -fsyntax-only -verify %s
@interface IDELogNavigator
{
id selectedObjects;
}
@end
@interface IDELogNavigator (CAT)
@property (readwrite, retain) id selectedObjects; // expected-note {{property declared here}}
@property (readwrite, retain) id d_selectedObjects; // expected-note {{property declared here}}
@end
@implementation IDELogNavigator
@synthesize selectedObjects = _selectedObjects; // expected-error {{property declared in category 'CAT' cannot be implemented in class implementation}}
@dynamic d_selectedObjects; // expected-error {{property declared in category 'CAT' cannot be implemented in class implementation}}
@end