diff options
| author | Justin Lebar <jlebar@google.com> | 2016-09-30 17:14:48 +0000 |
|---|---|---|
| committer | Justin Lebar <jlebar@google.com> | 2016-09-30 17:14:48 +0000 |
| commit | 0fad0ba6a9b0e4900a6e247831c83f665bde2a6b (patch) | |
| tree | e5e0c5e8e82343c08c01a1a578e26ffd3e3e2505 /clang/lib/Parse/ParseExprCXX.cpp | |
| parent | c5ed65ca3049e279e47692435111f30c09bbaa6b (diff) | |
| download | bcm5719-llvm-0fad0ba6a9b0e4900a6e247831c83f665bde2a6b.tar.gz bcm5719-llvm-0fad0ba6a9b0e4900a6e247831c83f665bde2a6b.zip | |
[CUDA] Handle attributes on CUDA lambdas appearing between [...] and (...).
Summary: This is ugh, but it makes us compatible with NVCC. Fixes bug 26341.
Reviewers: rnk
Subscribers: cfe-commits, tra
Differential Revision: https://reviews.llvm.org/D25103
llvm-svn: 282879
Diffstat (limited to 'clang/lib/Parse/ParseExprCXX.cpp')
| -rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 35661d51d09..2287e072730 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -1124,7 +1124,17 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( DeclSpec DS(AttrFactory); Declarator D(DS, Declarator::LambdaExprContext); TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth); - Actions.PushLambdaScope(); + Actions.PushLambdaScope(); + + ParsedAttributes Attr(AttrFactory); + SourceLocation DeclLoc = Tok.getLocation(); + SourceLocation DeclEndLoc = DeclLoc; + if (getLangOpts().CUDA) { + // In CUDA code, GNU attributes are allowed to appear immediately after the + // "[...]", even if there is no "(...)" before the lambda body. + MaybeParseGNUAttributes(Attr, &DeclEndLoc); + D.takeAttributes(Attr, DeclEndLoc); + } TypeResult TrailingReturnType; if (Tok.is(tok::l_paren)) { @@ -1133,13 +1143,11 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( Scope::FunctionDeclarationScope | Scope::DeclScope); - SourceLocation DeclEndLoc; BalancedDelimiterTracker T(*this, tok::l_paren); T.consumeOpen(); SourceLocation LParenLoc = T.getOpenLocation(); // Parse parameter-declaration-clause. - ParsedAttributes Attr(AttrFactory); SmallVector<DeclaratorChunk::ParamInfo, 16> ParamInfo; SourceLocation EllipsisLoc; @@ -1245,12 +1253,10 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( Diag(Tok, diag::err_lambda_missing_parens) << TokKind << FixItHint::CreateInsertion(Tok.getLocation(), "() "); - SourceLocation DeclLoc = Tok.getLocation(); - SourceLocation DeclEndLoc = DeclLoc; + DeclEndLoc = DeclLoc; // GNU-style attributes must be parsed before the mutable specifier to be // compatible with GCC. - ParsedAttributes Attr(AttrFactory); MaybeParseGNUAttributes(Attr, &DeclEndLoc); // Parse 'mutable', if it's there. @@ -1297,7 +1303,6 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( TrailingReturnType), Attr, DeclEndLoc); } - // FIXME: Rename BlockScope -> ClosureScope if we decide to continue using // it. |

