From 62d2e662ac26f1c53fc2ba5d2e6c4f4425511473 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 28 Jan 2007 00:21:37 +0000 Subject: [PATCH] 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 --- clang/AST/SemaDecl.cpp | 12 ++++++++---- clang/Sema/SemaDecl.cpp | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/clang/AST/SemaDecl.cpp b/clang/AST/SemaDecl.cpp index 408b1f546da5..cad75848ab34 100644 --- a/clang/AST/SemaDecl.cpp +++ b/clang/AST/SemaDecl.cpp @@ -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(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(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"); diff --git a/clang/Sema/SemaDecl.cpp b/clang/Sema/SemaDecl.cpp index 408b1f546da5..cad75848ab34 100644 --- a/clang/Sema/SemaDecl.cpp +++ b/clang/Sema/SemaDecl.cpp @@ -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(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(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");