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");