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

    <tr>
        <th>Summary</th>
        <td>
            Clang 17 and later rejects __attribute__ after static specifier in C++23 lambda expressions
        </td>
    </tr>

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

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

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

<pre>
    Here is a snippet of C++23 code that compiles successfully with GCC 13 or later with `-std=c++23` but fails to compile with Clang 17 or later (even with the `std=c++23` option):
```
#include <stddef.h>
#include <stdint.h>
#include <immintrin.h>

__m128i __attribute__((__target__("sse4.2"))) SomeFunc(
    const int32_t* src_ptr, size_t num_of_vectors) {
    auto process_func = [](const int32_t* p) static __attribute__((__target__("sse4.2"))) {
 __m128i v = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p));
 return _mm_mullo_epi32(v, _mm_set_epi32(15752961, 3969, 63, 1));
 };

    __m128i h = _mm_setzero_si128();
    for (size_t i = 0; i < num_of_vectors; i++) {
        h = _mm_add_epi32(_mm_sub_epi32(_mm_slli_epi32(h, 6), h),
 process_func(src_ptr + 4 * i));
    }
    return h;
}
```

The results of compiling the above snippet with GCC 13, Clang 17, and Clang trunk can be found at https://godbolt.org/z/WfoqnnPqc.

Should Clang be updated to allow `__attribute__((__target__("sse4.2")))` after the `static` specifier in C++23 lambda expressions?

On the other hand, the below snippet successfully compiles with Clang 17 or later in C++23 mode but fails to compile with GCC 13 in C++23 mode:
```
#include <stddef.h>
#include <stdint.h>
#include <immintrin.h>

__m128i __attribute__((__target__("sse4.2"))) SomeFunc(
    const int32_t* src_ptr, size_t num_of_vectors) {
    auto process_func = [](const int32_t* p) __attribute__((__target__("sse4.2"))) static {
 __m128i v = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p));
 return _mm_mullo_epi32(v, _mm_set_epi32(15752961, 3969, 63, 1));
 };

    __m128i h = _mm_setzero_si128();
    for (size_t i = 0; i < num_of_vectors; i++) {
        h = _mm_add_epi32(_mm_sub_epi32(_mm_slli_epi32(h, 6), h),
 process_func(src_ptr + 4 * i));
    }
    return h;
}
```

The results of compiling the above snippet with GCC 13, Clang 17, and Clang trunk can be found at https://godbolt.org/z/9ooT8bj1f.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsls-PqzYQx_8a5zLaCEx-wIHDJmnaWyu9J_WIDB6Ct8bm2eO8vv3rKxNCsrtdqVr18A4bIcBj_PXMeOajCO_VySCWbL1j68NCBOqsK59sZwYtiPyitvJH-Rs6BOVBgDdqGJDAtrBnfMf4jmfQWIlAnSBobD8ojR58aBr0vg1a_4Dvijr4db-HNAPrQAtCdzGyTfLgSbLs0FzV2CaBOhC0QmkPZK-alwV7LcwJ0u1Nh_Ecz2gu09Rh1PwXSTuQsobxgmWPLDmw5JFtkum6DHmmTKODRGDZ3pOU2C47lv3yzrQy9O606ntlyClz_8V4r6o-5bmCqhJETtWBsKoYzxnPq4qEOyFNY-49rpaccR6dHi_4Yns8BtPED0Y5AIDGGk-gDGW8IsYfwbumGsgxvgevnrEiMKGvbFudsSHrfFRi291NQQSyMDgbT6xqg2mAZQe4lATj-ZsNhqjgSZBqPhjIbftrQs7jnlXfV9oKGSqv0lHMoTKEbnBIVSM8sWx_8WdayPhjTDHPh0k9uyo7pODMKNkHrW2Fg8o44_k5ZiaaPdJsTNfbNS82aZzLik0Rn5ss3tPXwmx7mAe3JF4D6eZAPNIzOjuH8kIEAFo7Vu90Rmpcl7BsN77uXx9atF8K-s35xd9tWyHlHNXoRqhfjrVWs6Eb4xwj3EN3eU7C9wUR3bxUFTC-gxXEMlCvEwMw5mYeTCfQ3bJ1nX3de-P9a4fg0AdNPvLl0vfKnMauFrU944yfO6JEx69UiO_CyGlMLpi_oBEGaoTWBiNBEHREg48Q4EfGjycra6tpad2J8eMz48c_W_vNmD--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