[PATCH] D14905: [constexpr-lambda] Support parsing of constexpr specifier (and its inference) on lambda expressions

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 25 18:31:54 PDT 2016


rsmith accepted this revision.
This revision is now accepted and ready to land.

================
Comment at: include/clang/Basic/DiagnosticParseKinds.td:769
@@ +768,3 @@
+  "attribute specifier|'constexpr'}0">;
+def err_lambda_declspecifier_repeated : Error<
+  "%select{'mutable'|'constexpr'}0 cannot appear multiple times in a lambda declarator">;
----------------
declspecifier -> decl_specifier

================
Comment at: lib/AST/ExprConstant.cpp:2049-2063
@@ -2047,3 +2048,17 @@
     Result = Frame->getTemporary(VD);
+    if (!Result && isLambdaCallOperator(Frame->Callee) &&
+        (VD->getDeclContext() != Frame->Callee || VD->isInitCapture())) {
+      // Assume variables referenced within a lambda's call operator that were
+      // not declared within the call operator are captures and during checking
+      // of a potential constant expression, assume they are unknown constant
+      // expressions. 
+      if (Info.checkingPotentialConstantExpression())
+        return false;
+      // FIXME: implement capture evaluation during constant expr evaluation.
+      Info.Diag(E->getLocStart(),
+           diag::note_unimplemented_constexpr_lambda_feature_ast)
+          << "captures not currently allowed";
+      return false;
+    }
     assert(Result && "missing value for local variable");
     return true;
----------------
I'd prefer to phrase this if/assert arrangement as:

  if (!Result) {
    assert(isLambdaCallOperator(...) && (VD->getDeclContext != ...

================
Comment at: lib/Parse/ParseExprCXX.cpp:1077
@@ +1076,3 @@
+    default:
+      return ;
+    }
----------------
No space before `;`.


http://reviews.llvm.org/D14905





More information about the cfe-commits mailing list