diff options
| author | Steve Naroff <snaroff@apple.com> | 2009-03-05 15:22:01 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2009-03-05 15:22:01 +0000 |
| commit | 41d09add4fd46ef680ca81c489bbd374620f82f2 (patch) | |
| tree | 1c2e3d8213de001483a9ea0e19520cb6ecdebeba /clang/lib/Sema/SemaDeclObjC.cpp | |
| parent | 96f52eb13fcab129e8d6daecfba295c2e55ccbb8 (diff) | |
| download | bcm5719-llvm-41d09add4fd46ef680ca81c489bbd374620f82f2.tar.gz bcm5719-llvm-41d09add4fd46ef680ca81c489bbd374620f82f2.zip | |
Fix <rdar://problem/6144382> [sema] gcc inconsistency w.r.t. forward protocol declarations.
llvm-svn: 66161
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 55b0d16e8c4..d90f2adc77a 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -215,6 +215,25 @@ Sema::DeclTy *Sema::ActOnCompatiblityAlias(SourceLocation AtLoc, return AliasDecl; } +void Sema::CheckForwardProtocolDeclarationForCircularDependency( + IdentifierInfo *PName, + SourceLocation &Ploc, SourceLocation PrevLoc, + const ObjCList<ObjCProtocolDecl> &PList) +{ + for (ObjCList<ObjCProtocolDecl>::iterator I = PList.begin(), + E = PList.end(); I != E; ++I) { + + if (ObjCProtocolDecl *PDecl = ObjCProtocols[(*I)->getIdentifier()]) { + if (PDecl->getIdentifier() == PName) { + Diag(Ploc, diag::err_protocol_has_circular_dependency); + Diag(PrevLoc, diag::note_previous_definition); + } + CheckForwardProtocolDeclarationForCircularDependency(PName, Ploc, + PDecl->getLocation(), PDecl->getReferencedProtocols()); + } + } +} + Sema::DeclTy * Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, @@ -236,6 +255,12 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, // FIXME: don't leak the objects passed in! return PDecl; } + ObjCList<ObjCProtocolDecl> PList; + PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context); + CheckForwardProtocolDeclarationForCircularDependency( + ProtocolName, ProtocolLoc, PDecl->getLocation(), PList); + PList.Destroy(Context); + // Make sure the cached decl gets a valid start location. PDecl->setLocation(AtProtoInterfaceLoc); PDecl->setForwardDecl(false); |

