]> granicus.if.org Git - clang/commit
[Cxx1z-constexpr-lambda-P0170R1] Support parsing of constexpr specifier (and its...
authorFaisal Vali <faisalv@yahoo.com>
Sat, 26 Mar 2016 16:11:37 +0000 (16:11 +0000)
committerFaisal Vali <faisalv@yahoo.com>
Sat, 26 Mar 2016 16:11:37 +0000 (16:11 +0000)
commita46d5cd16e126e77646365b8a5c6f3d0db28b5d0
tree7f030d5f8561163b8c74da4828abcb7c52755af0
parenta770469c09407dcba821d1a575300ac69274516d
[Cxx1z-constexpr-lambda-P0170R1]  Support parsing of constexpr specifier (and its inference) on lambda expressions

Support the constexpr specifier on lambda expressions - and support its inference from the lambda call operator's body.

i.e.
  auto L = [] () constexpr { return 5; };
  static_assert(L() == 5); // OK
  auto Implicit = [] (auto a) { return a; };
  static_assert(Implicit(5) == 5);

We do not support evaluation of lambda's within constant expressions just yet.

Implementation Strategy:
  - teach ParseLambdaExpressionAfterIntroducer to expect a constexpr specifier and mark the invented function call operator's declarator's decl-specifier with it; Have it emit fixits for multiple decl-specifiers (mutable or constexpr) in this location.
  - for cases where constexpr is not explicitly specified, have buildLambdaExpr check whether the invented function call operator satisfies the requirements of a constexpr function, by calling CheckConstexprFunctionDecl/Body.

Much obliged to Richard Smith for his patience and his care, in ensuring the code is clang-worthy.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@264513 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticASTKinds.td
include/clang/Basic/DiagnosticParseKinds.td
include/clang/Sema/Sema.h
lib/AST/ExprConstant.cpp
lib/Parse/ParseExprCXX.cpp
lib/Sema/SemaLambda.cpp
lib/Sema/TreeTransform.h
test/Parser/cxx1z-constexpr-lambdas.cpp [new file with mode: 0644]
test/SemaCXX/cxx1z-constexpr-lambdas.cpp [new file with mode: 0644]