[PATCH] D28510: Reinstate CWG1607 restrictions on lambdas appearing inside certain constant-expressions

Faisal Vali via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 9 20:13:00 PST 2017


faisalv created this revision.
faisalv added a reviewer: rsmith.
faisalv added a subscriber: cfe-commits.
faisalv set the repository for this revision to rL LLVM.
faisalv added a project: clang-c.

This patch disables lambda expressions (especially Immediately Invoked Lambda Expressions (IILEs, to borrow a term from the all-mighty ecmascript ;)) from appearing within potentially mangled contexts.

The approach is a rather primitive/inelegant one.  Instead of enumerating all the various syntactic constant-expression contexts at a finer level of granularity and then passing that information through to each call of ParseConstantExpression, we simply set a flag that forbids lambda expressions (when we know we are in the forbidden context).  There is probably an opportunity here to streamline the machinery that prohibits lambdas in certain contexts across the various versions of C++ further - but that could be re-engineered if/when Louis Dionne's paper on Lambdas in Unevaluated contexts gets incorporated into the working draft.

Would appreciate some feedback here - thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D28510

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/cxx1z-constexpr-lambdas.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28510.83771.patch
Type: text/x-patch
Size: 12076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170110/88e3de81/attachment-0001.bin>


More information about the cfe-commits mailing list