[PATCH] D146140: [clang] Properly parse variable template requires clause in lambda

Emilia Dreamer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 15 07:50:12 PDT 2023


rymiel created this revision.
rymiel added a project: clang.
rymiel added reviewers: aaron.ballman, erichkeane.
Herald added a project: All.
rymiel requested review of this revision.
Herald added a subscriber: cfe-commits.

Since P0857, part of C++20, a *lambda-expression* can contain a
*requires-clause* after its *template-parameter-list*.

While support for this was added as part of
eccc734a69c0c012ae3160887b65a535b35ead3e <https://reviews.llvm.org/rGeccc734a69c0c012ae3160887b65a535b35ead3e>, one specific case isn't
handled properly, where the *requires-clause* consists of an
instantiation of a boolean variable template. This is due to a
diagnostic check which was written with the assumption that a
*requires-clause* can never be followed by a left parenthesis. This
assumption no longer holds for lambdas.

This diagnostic check would then attempt to perform a "recovery", but it
does so in a valid parse state, resulting in an invalid parse state
instead!

This patch adds a special case when parsing requires clauses of lambda
templates, to skip this diagnostic check.

Fixes https://github.com/llvm/llvm-project/issues/61278
Fixes https://github.com/llvm/llvm-project/issues/61387


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146140

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/test/SemaTemplate/concepts.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146140.505489.patch
Type: text/x-patch
Size: 6342 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230315/6ae7392d/attachment-0001.bin>


More information about the cfe-commits mailing list