When injecting a definition for implicitly defined functions, do so at

translation-unit scope, so we only warn about each implicitly defined
function once.  This cuts the number of errors parsing carbon.h from 616 to 550.

llvm-svn: 39325
This commit is contained in:
Chris Lattner 2007-01-28 00:21:37 +00:00
parent efe4aea064
commit 62d2e662ac
2 changed files with 16 additions and 8 deletions

View File

@ -337,11 +337,11 @@ Decl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, 0, 0, Loc));
D.SetIdentifier(&II, Loc);
Decl *Result = static_cast<Decl*>(ParseDeclarator(S, D, 0, 0));
// Find translation-unit scope to insert this function into.
while (S->getParent())
S = S->getParent();
// Visit this implicit declaration like any other top-level form.
LastInGroupList.push_back(Result);
return Result;
return static_cast<Decl*>(ParseDeclarator(S, D, 0, 0));
}
@ -458,6 +458,10 @@ Sema::DeclTy *Sema::ParseField(Scope *S, DeclTy *TagDecl,
SourceLocation Loc = DeclStart;
if (II) Loc = D.getIdentifierLoc();
// FIXME: Unnamed fields can be handled in various different ways, for
// example, unnamed unions inject all members into the struct namespace!
if (BitWidth) {
// TODO: Validate.
printf("WARNING: BITFIELDS IGNORED!\n");

View File

@ -337,11 +337,11 @@ Decl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, 0, 0, Loc));
D.SetIdentifier(&II, Loc);
Decl *Result = static_cast<Decl*>(ParseDeclarator(S, D, 0, 0));
// Find translation-unit scope to insert this function into.
while (S->getParent())
S = S->getParent();
// Visit this implicit declaration like any other top-level form.
LastInGroupList.push_back(Result);
return Result;
return static_cast<Decl*>(ParseDeclarator(S, D, 0, 0));
}
@ -458,6 +458,10 @@ Sema::DeclTy *Sema::ParseField(Scope *S, DeclTy *TagDecl,
SourceLocation Loc = DeclStart;
if (II) Loc = D.getIdentifierLoc();
// FIXME: Unnamed fields can be handled in various different ways, for
// example, unnamed unions inject all members into the struct namespace!
if (BitWidth) {
// TODO: Validate.
printf("WARNING: BITFIELDS IGNORED!\n");