[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)
commita734ab9808658310b63e5a945f21837076dd14c7
tree0261e163817fe9adae255dec91c851dc2f4793c6
parente4dbeb40c6a08abb5486c25ab0b31926f10d6248
[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.

llvm-svn: 264513
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/TreeTransform.h
clang/test/Parser/cxx1z-constexpr-lambdas.cpp [new file with mode: 0644]
clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp [new file with mode: 0644]