зеркало из https://github.com/microsoft/clang-1.git
Start supporting declaration of ivars in @implementation
blocks. WIP. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96696 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
1f4646659f
Коммит
bd94d442f6
|
@ -253,6 +253,12 @@ def err_dup_implementation_category : Error<
|
|||
"reimplementation of category %1 for class %0">;
|
||||
def err_conflicting_ivar_type : Error<
|
||||
"instance variable %0 has conflicting type: %1 vs %2">;
|
||||
def err_duplicate_ivar_declaration : Error<
|
||||
"instance variable is already declared">;
|
||||
def warn_on_superclass_use : Warning<
|
||||
"class implementation may not have super class">;
|
||||
def err_non_private_ivar_declaration : Error<
|
||||
"only private ivars may be declared in implementation">;
|
||||
def err_conflicting_ivar_bitwidth : Error<
|
||||
"instance variable %0 has conflicting bit-field width">;
|
||||
def err_conflicting_ivar_name : Error<
|
||||
|
|
|
@ -836,7 +836,26 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
|
|||
return;
|
||||
|
||||
assert(ivars && "missing @implementation ivars");
|
||||
|
||||
if (LangOpts.ObjCNonFragileABI2) {
|
||||
if (ImpDecl->getSuperClass())
|
||||
Diag(ImpDecl->getLocation(), diag::warn_on_superclass_use);
|
||||
for (unsigned i = 0; i < numIvars; i++) {
|
||||
ObjCIvarDecl* ImplIvar = ivars[i];
|
||||
if (const ObjCIvarDecl *ClsIvar =
|
||||
IDecl->getIvarDecl(ImplIvar->getIdentifier())) {
|
||||
Diag(ImplIvar->getLocation(), diag::err_duplicate_ivar_declaration);
|
||||
Diag(ClsIvar->getLocation(), diag::note_previous_definition);
|
||||
continue;
|
||||
}
|
||||
if (ImplIvar->getAccessControl() != ObjCIvarDecl::Private)
|
||||
Diag(ImplIvar->getLocation(), diag::err_non_private_ivar_declaration);
|
||||
// Instance ivar to Implementation's DeclContext.
|
||||
ImplIvar->setLexicalDeclContext(ImpDecl);
|
||||
IDecl->makeDeclVisibleInContext(ImplIvar, false);
|
||||
ImpDecl->addDecl(ImplIvar);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Check interface's Ivar list against those in the implementation.
|
||||
// names and types must match.
|
||||
//
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi2 -verify %s
|
||||
|
||||
@interface Super @end
|
||||
|
||||
@interface INTFSTANDALONE : Super
|
||||
{
|
||||
id IVAR; // expected-note {{previous definition is here}}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation INTFSTANDALONE : Super // expected-warning {{class implementation may not have super class}}
|
||||
{
|
||||
@private
|
||||
id IVAR1;
|
||||
@protected
|
||||
id IVAR2; // expected-error {{only private ivars may be declared in implementation}}
|
||||
@private
|
||||
id IVAR3;
|
||||
int IVAR; // expected-error {{instance variable is already declared}}
|
||||
}
|
||||
@end
|
Загрузка…
Ссылка в новой задаче