[PATCH] D146030: [clang][Interp] Handle LambdaExprs

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 8 14:14:39 PDT 2023


shafik added inline comments.


================
Comment at: clang/test/AST/Interp/lambda.cpp:5
+constexpr int a = 12;
+constexpr int f = [c = a]() { return c; }();
+static_assert(f == a);
----------------
Fun case

```
int constexpr f() {
    return [x = 10] {
       decltype(x) y; // type int b/c not odr use
                      // refers to original init-capture
       auto &z = x; // type const int & b/c odr use
                     // refers to lambdas copy of x
        y = 10; // Ok
        //z = 10; // Ill-formed
        return y;
    }();
}

constexpr int x = f();
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146030/new/

https://reviews.llvm.org/D146030



More information about the cfe-commits mailing list