<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59549>59549</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang]  Captured attribute argument on lambda throws weird error
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          elizabethandrews
      </td>
    </tr>
</table>

<pre>
    ```
void foo () {
  constexpr int i = 2;

  [&]() {
    [=]() [[clang::annotate_type("test", i)]]{};
 };
}

<source>:5:42: error: variable 'i' cannot be implicitly captured in a lambda with no capture-default specified
    [=]() [[clang::annotate_type("test", i)]]{};
 ^
<source>:2:17: note: 'i' declared here
  constexpr int i = 2;
```

Moving the captured variable to outer lambda scope fixes the error - https://godbolt.org/z/sPWx9aK5T
Capturing variable inside lambda body (instead of attribute argument) works - https://godbolt.org/z/z79jM9GMc
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VMFu4zgM_Rr6QiSwJTteHXxI42YPiwJ7WGCPA9liYnUUy5DopO3XD-Q0bWc6h54GMCwZT-Tje6SlY7THkaiB6g6qNtMzDz405OyL7ogHPZpAl5h13jw3sMlfn7yFfHv21uDBewTxFwiFUN9dAcTej5HpaQpoR0aLIFsUIF_x26nEKTZQtZ8TXEHZfgBTgXe90-MR5BbkVo-jZ830jZ8nWg4JpsggBIgdWhAqBVdtylq3b-T48SPtP5QEchf9HHoCeQ9yW4HclgLkFikEH9LmrIPVnSMEUVsQNfZLGdgR2tPkbG_ZPWOvJ54DGbQjanT61BmNF8sDjv4Grgwd9OwY40S9PVgyf0J7df9bpUlkUSeBo2dK602fod7pJGWgQF9s789jcn0_-LMdj8gDvbvzZiZ79DNTuFkVez8RHuwTxSVisR9XODBPMTkg9iD2R28673jtwxHE_gXEPv77_5PS_1T_XTl3C1GifWOyY7SGbjxpqtP02iRHG_QH1MzBdjMT6nCcTzRyasDFh-_xCwW81OrxQf390GemkUZJpTNqik1dFKqsC5UNDdVKF-WB6sNGVRshTWFkWRqttOrKuiwy24hciEIUm0KUVaHWnSpzQUaqnpTMlYYyp5O2bu3c-ZS4MxvjTE2lqlJlTnfk4vI7CzHSBRcwDUbVZqFJMatuPkYoc2cjx_csbNkt98BumbOqRdzdOvXZFfTjzUUegr9EvJAN5tqqbA6u-cUry8PcrXt_ArFPnK_Lagr-kXoGsV8qjSD2i5IfAQAA___yrWFa">