[cfe-commits] r61161 - /cfe/trunk/lib/Sema/SemaDecl.cpp
Fariborz Jahanian
fjahanian at apple.com
Wed Dec 17 14:21:45 PST 2008
Author: fjahanian
Date: Wed Dec 17 16:21:44 2008
New Revision: 61161
URL: http://llvm.org/viewvc/llvm-project?rev=61161&view=rev
Log:
Patch to re-implement duplicate ivar checking
(which will pass duplicate-ivar-check.m test again).
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=61161&r1=61160&r2=61161&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Dec 17 16:21:44 2008
@@ -3029,27 +3029,20 @@
ObjCIvarDecl **ClsFields = reinterpret_cast<ObjCIvarDecl**>(&RecFields[0]);
if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(EnclosingDecl)) {
ID->addInstanceVariablesToClass(ClsFields, RecFields.size(), RBrac);
-#if 0
// Must enforce the rule that ivars in the base classes may not be
// duplicates.
- FieldIDs.clear();
- RecordDecl *RD = ID->getRecordForDecl();
- for (RecordDecl::field_iterator i = RD->field_begin(),
- e = RD->field_end(); i != e; ++i) {
- FieldDecl *FD = *i;
- if (IdentifierInfo *II = FD->getIdentifier())
- if (!FieldIDs.insert(II)) {
- Diag(FD->getLocation(), diag::err_duplicate_member) << II;
- FD->setInvalidDecl();
- for (RecordDecl::field_iterator j = RD->field_begin(),
- e1 = RD->field_end(); j != e1; ++j)
- if (II == (*j)->getIdentifier()) {
- Diag((*j)->getLocation(), diag::note_previous_definition);
- break;
- }
+ if (ID->getSuperClass()) {
+ for (ObjCInterfaceDecl::ivar_iterator IVI = ID->ivar_begin(),
+ IVE = ID->ivar_end(); IVI != IVE; ++IVI) {
+ ObjCIvarDecl* Ivar = (*IVI);
+ IdentifierInfo *II = Ivar->getIdentifier();
+ ObjCIvarDecl* prevIvar = ID->getSuperClass()->FindIvarDeclaration(II);
+ if (prevIvar) {
+ Diag(Ivar->getLocation(), diag::err_duplicate_member) << II;
+ Diag(prevIvar->getLocation(), diag::note_previous_definition);
}
+ }
}
-#endif
}
else if (ObjCImplementationDecl *IMPDecl =
dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
More information about the cfe-commits
mailing list