================
@@ -748,6 +748,23 @@ ExprResult Parser::TryParseLambdaExpression() {
return ParseLambdaExpressionAfterIntroducer(Intro);
}
+bool Parser::startsLambdaNotMicrosoftAttribute() {
+ // Restricted to CUDA/HIP, the only mode that allows attributes immediately
+ // after a lambda's capture list.
+ if (!getLangOpts().CUDA || Tok.isNot(tok::l_square))
+ return false;
+
+ // Skip the '[...]' and any trailing attributes (e.g. CUDA/HIP's
+ // '__device__'). A lambda then continues with '(', '{' or '<', while an
+ // attribute is followed by the declaration it applies to (e.g. '[propget]
+ // int get()').
+ RevertingTentativeParsingAction TPA(*this);
+ ConsumeBracket();
+ if (!SkipUntil(tok::r_square, StopAtSemi) || !TrySkipAttributes())
+ return false;
+ return Tok.isOneOf(tok::l_paren, tok::l_brace, tok::less);
----------------
yxsamliu wrote:
The lookahead only recognizes `(`, `{`, or `<` after CUDA/HIP attributes. C++23
also allows forms such as `[] __device__ noexcept {}` and `[] __device__ -> int
{ return 1; }`, which would still be parsed as Microsoft attributes. Could this
use the same continuation rules as the lambda parser and add tests for these
forms?
https://github.com/llvm/llvm-project/pull/214247
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits