From: Chris Lattner Date: Sun, 7 Oct 2007 07:05:08 +0000 (+0000) Subject: The identifier shouldn't be added to the scope, the decl should. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=60c52187e0c4d84e995f92ca89be87582ab45b1a;p=clang The identifier shouldn't be added to the scope, the decl should. This fixes strange assertions that just started triggering. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42721 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 94230a79ee..d870ab4d21 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -1039,16 +1039,18 @@ Sema::ActOnForwardProtocolDeclaration(Scope *S, SourceLocation AtProtocolLoc, llvm::SmallVector Protocols; for (unsigned i = 0; i != NumElts; ++i) { - ObjcProtocolDecl *PDecl = getObjCProtocolDecl(S, IdentList[i], - AtProtocolLoc); - if (!PDecl) { // Already seen? - PDecl = new ObjcProtocolDecl(SourceLocation(), 0, IdentList[i], true); + IdentifierInfo *P = IdentList[i]; + ObjcProtocolDecl *PDecl = getObjCProtocolDecl(S, P, AtProtocolLoc); + if (!PDecl) { // Not already seen? + // FIXME: Pass in the location of the identifier! + PDecl = new ObjcProtocolDecl(AtProtocolLoc, 0, P, true); // Chain & install the protocol decl into the identifier. PDecl->setNext(IdentList[i]->getFETokenInfo()); IdentList[i]->setFETokenInfo(PDecl); + + // Remember that this needs to be removed when the scope is popped. + S->AddDecl(PDecl); } - // Remember that this needs to be removed when the scope is popped. - S->AddDecl(IdentList[i]); Protocols.push_back(PDecl); } @@ -1364,9 +1366,10 @@ Sema::ActOnForwardClassDeclaration(Scope *S, SourceLocation AtClassLoc, // Chain & install the interface decl into the identifier. IDecl->setNext(IdentList[i]->getFETokenInfo()); IdentList[i]->setFETokenInfo(IDecl); + + // Remember that this needs to be removed when the scope is popped. + S->AddDecl(IDecl); } - // Remember that this needs to be removed when the scope is popped. - S->AddDecl(IdentList[i]); Interfaces.push_back(IDecl); }