aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r--lib/Parse/ParseDecl.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 1f9f85bab7..c5cedeafbb 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -759,8 +759,28 @@ void Parser::ParseLexedAttribute(LateParsedAttribute &LA) {
ParsedAttributes Attrs(AttrFactory);
SourceLocation endLoc;
+ // If the Decl is templatized, add template parameters to scope.
+ bool HasTemplateScope = LA.D && LA.D->isTemplateDecl();
+ ParseScope TempScope(this, Scope::TemplateParamScope, HasTemplateScope);
+ if (HasTemplateScope)
+ Actions.ActOnReenterTemplateScope(Actions.CurScope, LA.D);
+
+ // If the Decl is on a function, add function parameters to the scope.
+ bool HasFunctionScope = LA.D && LA.D->isFunctionOrFunctionTemplate();
+ ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope, HasFunctionScope);
+ if (HasFunctionScope)
+ Actions.ActOnReenterFunctionContext(Actions.CurScope, LA.D);
+
ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc);
+ if (HasFunctionScope) {
+ Actions.ActOnExitFunctionContext();
+ FnScope.Exit(); // Pop scope, and remove Decls from IdResolver
+ }
+ if (HasTemplateScope) {
+ TempScope.Exit();
+ }
+
// Late parsed attributes must be attached to Decls by hand. If the
// LA.D is not set, then this was not done properly.
assert(LA.D && "No decl attached to late parsed attribute");