diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-11-10 18:01:36 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-11-10 18:01:36 +0000 |
commit | a0a9d85a5d14e4e12fe08477f2837c6d276802f0 (patch) | |
tree | f875044aea0c03f951f29d5d44a4828fc54bdc4b /clang/lib/Sema/SemaObjCProperty.cpp | |
parent | ca21cd749e17917e55b5cd36305c1a470c7d3dc0 (diff) | |
download | bcm5719-llvm-a0a9d85a5d14e4e12fe08477f2837c6d276802f0.tar.gz bcm5719-llvm-a0a9d85a5d14e4e12fe08477f2837c6d276802f0.zip |
Check for duplicate declaration of a property in current and
other class extensions. // rdar://7629420
llvm-svn: 118689
Diffstat (limited to 'clang/lib/Sema/SemaObjCProperty.cpp')
-rw-r--r-- | clang/lib/Sema/SemaObjCProperty.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index 37f9db1e5be..e1c0f4af99e 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -93,14 +93,22 @@ Sema::HandlePropertyInClassExtension(Scope *S, ObjCCategoryDecl *CDecl, // Diagnose if this property is already in continuation class. DeclContext *DC = cast<DeclContext>(CDecl); IdentifierInfo *PropertyId = FD.D.getIdentifier(); - - if (ObjCPropertyDecl *prevDecl = - ObjCPropertyDecl::findPropertyDecl(DC, PropertyId)) { - Diag(AtLoc, diag::err_duplicate_property); - Diag(prevDecl->getLocation(), diag::note_property_declare); - return 0; - } - + ObjCInterfaceDecl *CCPrimary = CDecl->getClassInterface(); + + if (CCPrimary) + // Check for duplicate declaration of this property in current and + // other class extensions. + for (const ObjCCategoryDecl *ClsExtDecl = + CCPrimary->getFirstClassExtension(); + ClsExtDecl; ClsExtDecl = ClsExtDecl->getNextClassExtension()) { + if (ObjCPropertyDecl *prevDecl = + ObjCPropertyDecl::findPropertyDecl(ClsExtDecl, PropertyId)) { + Diag(AtLoc, diag::err_duplicate_property); + Diag(prevDecl->getLocation(), diag::note_property_declare); + return 0; + } + } + // Create a new ObjCPropertyDecl with the DeclContext being // the class extension. ObjCPropertyDecl *PDecl = @@ -115,7 +123,6 @@ Sema::HandlePropertyInClassExtension(Scope *S, ObjCCategoryDecl *CDecl, // We need to look in the @interface to see if the @property was // already declared. - ObjCInterfaceDecl *CCPrimary = CDecl->getClassInterface(); if (!CCPrimary) { Diag(CDecl->getLocation(), diag::err_continuation_class); *isOverridingProperty = true; |