diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2014-06-25 17:09:41 +0000 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2014-06-25 17:09:41 +0000 |
commit | a826147eef05d1d4fa0f3efdd1eeb4c71ae13b9d (patch) | |
tree | 4d955aea3d73adfaaa7fe5b3097fc1b8f603293f /clang/lib/AST/Decl.cpp | |
parent | 9029bda8a31c6d2f908fd1d6e6e4d8615c8c76c7 (diff) | |
download | bcm5719-llvm-a826147eef05d1d4fa0f3efdd1eeb4c71ae13b9d.tar.gz bcm5719-llvm-a826147eef05d1d4fa0f3efdd1eeb4c71ae13b9d.zip |
Fix treatment of types defined in function prototype
Types defined in function prototype are diagnosed earlier in C++ compilation.
They are put into declaration context where the prototype is introduced. Later on,
when FunctionDecl object is created, these types are moved into the function context.
This patch fixes PR19018 and PR18963.
Differential Revision: http://reviews.llvm.org/D4145
llvm-svn: 211718
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 7234d4c8327..d910a669abf 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2544,6 +2544,18 @@ void FunctionDecl::setDeclsInPrototypeScope(ArrayRef<NamedDecl *> NewDecls) { NamedDecl **A = new (getASTContext()) NamedDecl*[NewDecls.size()]; std::copy(NewDecls.begin(), NewDecls.end(), A); DeclsInPrototypeScope = ArrayRef<NamedDecl *>(A, NewDecls.size()); + // Move declarations introduced in prototype to the function context. + for (auto I : NewDecls) { + DeclContext *DC = I->getDeclContext(); + // Forward-declared reference to an enumeration is not added to + // declaration scope, so skip declaration that is absent from its + // declaration contexts. + if (DC->containsDecl(I)) { + DC->removeDecl(I); + I->setDeclContext(this); + addDecl(I); + } + } } } |