llvm-project/clang/test/SemaCXX/libstdcxx_format_kind_hack.cpp
Yanzuo Liu 86ba681e28
[Clang][Sema] Disable checking invalid template id in initializer of primary variable template std::format_kind with libstdc++ (#139560)
#134522 triggers compilation error with libstdc++, in which primary
variable template `std::format_kind` is defined like

```cpp
template <typename R>
constexpr auto format_kind =
__primary_template_not_defined(
  format_kind<R>
);
```

See #139067 or <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120190>.

This PR disables checking template id in initializer of primary variable
template `std::format_kind` in libstdc++ (by checking `__GLIBCXX__`).

Fixes #139067
2025-05-14 10:25:01 +02:00

18 lines
443 B
C++

// RUN: %clang_cc1 -fsyntax-only -std=c++23 -verify %s
// expected-no-diagnostics
// Primary variable template std::format_kind is defined as followed since
// libstdc++ 15.1, which triggers compilation error introduced by GH134522.
// This file tests the workaround.
#define __GLIBCXX__ 20250513
namespace std {
template<typename _Rg>
constexpr auto format_kind =
__primary_template_not_defined(
format_kind<_Rg>
);
}