Apply __no_specializations__ to several C++ standard library templates
Attribute added to library templates to prevent unintended specializations, resolving LWG issues.
The _Clang::__no_specializations__ attribute has been applied to several C++ standard library templates, including std::variant, std::tuple, std::initializer_list, and std::type_order. This change aims to prevent ill-formed specializations that would otherwise lead to compilation errors, addressing Library Working Group (LWG) issues.
In Details
This commit applies the _GLIBCXX_NO_SPECIALIZATIONS macro (aliased from _Clang::__no_specializations__) to various standard library components like std::variant, std::tuple, std::format contexts, and std::type_order. This is done to enforce the intent of LWG resolutions (e.g., LWG3990, LWG3975, LWG4305, LWG2129) that specify these templates should not be specialized by users, thus causing ill-formed code when they are, rather than just undefined behavior (IFNDR). New test cases are added for each LWG resolution.
- _Clang::__no_specializations__
- A non-standard attribute, often used by Clang, that prevents user-defined specializations of a template. GCC implements this via the
_GLIBCXX_NO_SPECIALIZATIONSmacro. - libstdc++
- The C++ standard library implementation used by GCC.
- LWG
- Library Working Group, a committee that works on proposals and defect reports for the C++ Standard Library.
- std::variant
- A C++ standard library type that represents a type-safe union, capable of holding a value of one of several alternative types.
- std::tuple
- A C++ standard library template that represents a fixed-size collection of heterogeneous values.
- ill-formed
- In C++, code that violates the language's syntax or semantic rules and cannot be compiled, as opposed to code that compiles but has undefined behavior.