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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Clang rejects anonymous struct with generic lambda while GCC/MSVC accept
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    Clang rejects following C++ code containing generic lambda in anonymous struct's member function, while both GCC and MSVC accept the same code.  This affects all forms of generic lambdas like `auto&x`, `auto... x`.
- Here is the reproducer: https://godbolt.org/z/1ehMYbsT8 
- _**Generated by fuzzer.**_

## Program
```cpp
typedef struct {
    void foo() {
 auto f = [](auto&& x) {};
        f(f);
    }
} Test;
```

## Clang Output
```bash
<source>:1:15: error: anonymous non-C-compatible type given name for linkage purposes by typedef declaration after its linkage was computed; add a tag name here to establish linkage prior to definition
    1 | typedef struct {
      |               ^
      | Test
<source>:2:5: note: type is not C-compatible due to this member declaration
    2 |     void foo() {
      |     ^~~~~~~~~~~~
    3 | auto f = [](auto&& x) {};
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~
 4 |         f(f);
      |         ~~~~~
    5 |     }
      | ~
<source>:6:3: note: type is given name 'Test' for linkage purposes by this typedef declaration
    6 | } Test;
      |   ^
1 error generated.
Compiler returned: 1
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVUtvpDgQ_jXVl1KQMa_OgQMh09nLaFfaaLV7GhkowDvGRrZJJjnkt68MnXR3Hpe1aKGuKurx-asq4ZwcNFEJ2Q1ktzux-NHY8m8thdk1pnsqayX0gJb-pdY77I1S5lHqAWvgN8BvsDUdYWu0F1IH-UCarGxRianpBEqNQhv9NJnFofN2aT3wwuFEU0MW-0W3XhoNvMbHUSrCxvgR7-oahe7w-59_1SjalmaPfiR0YqI1Yo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