diff options
author | James Molloy <james.molloy@arm.com> | 2012-02-28 18:12:11 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2012-02-28 18:12:11 +0000 |
commit | fbcf0405b7da1c8606e4223b4f91835643ecd5b4 (patch) | |
tree | 94f15f288c984dd3be38734e6c2f1e04c5d53c2d /lib/AST/Decl.cpp | |
parent | f911242f43ae1b0a85c323631fe817df95c9cbe9 (diff) |
Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped.
This fixes code such as:
enum e {x, y};
int f(enum {y, x} n) {
return 0;
}
This finally fixes PR5464 and PR5477.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151638 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 433ce100cf..bd7579996f 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -1847,6 +1847,16 @@ void FunctionDecl::setParams(ASTContext &C, } } +void FunctionDecl::setDeclsInPrototypeScope(llvm::ArrayRef<NamedDecl *> NewDecls) { + assert(DeclsInPrototypeScope.empty() && "Already has prototype decls!"); + + if (!NewDecls.empty()) { + NamedDecl **A = new (getASTContext()) NamedDecl*[NewDecls.size()]; + std::copy(NewDecls.begin(), NewDecls.end(), A); + DeclsInPrototypeScope = llvm::ArrayRef<NamedDecl*>(A, NewDecls.size()); + } +} + /// getMinRequiredArguments - Returns the minimum number of arguments /// needed to call this function. This may be fewer than the number of /// function parameters, if some of the parameters have default |