From: Jakub Jelinek Date: Tue, 3 Feb 2026 13:22:46 +0000 (+0100) Subject: libstdc++: Define __cpp_lib_define_static [PR123921] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a514ea759f6045ef091504f2afcf4b618fe2639;p=thirdparty%2Fgcc.git libstdc++: Define __cpp_lib_define_static [PR123921] I've totally missed the P3491R3 paper (define_static_{string,object,array}) comes with its own feature test macro - __cpp_lib_define_static 202506 which should appear in and . The paper contains 3 parts, std::is_string_literal, std::meta::reflect_constant_{string,array} and std::define_static_{string,object,array}. The first part is implementable without reflection, the third part in theory would be also implementable without reflection but usually will be (and in libstdc++ is) implemented using reflection, and the middle part is really part of reflection. So dunno how useful this FTM actually is, maybe just for cases where some implementation does implement reflection and doesn't implement this paper for a while. Anyway, the FTM is in C++26 draft, so this patch adds it, with the same condition as __cpp_lib_reflection. 2026-02-03 Jakub Jelinek PR libstdc++/123921 * include/bits/version.def (define_static): New with the same values as reflection. * include/bits/version.h: Regenerate. * include/std/meta: Define also __glibcxx_want_define_static before including bits/version.h. * g++.dg/reflect/feat2.C: Add also test for __cpp_lib_define_static. * g++.dg/reflect/feat3.C: New test. --- diff --git a/gcc/testsuite/g++.dg/reflect/feat2.C b/gcc/testsuite/g++.dg/reflect/feat2.C index 902732b0824..dc4c82cdaab 100644 --- a/gcc/testsuite/g++.dg/reflect/feat2.C +++ b/gcc/testsuite/g++.dg/reflect/feat2.C @@ -9,3 +9,9 @@ #elif __cpp_lib_reflection != 202506 # error "__cpp_lib_reflection != 202506" #endif + +#ifndef __cpp_lib_define_static +# error "__cpp_lib_define_static" +#elif __cpp_lib_define_static != 202506 +# error "__cpp_lib_define_static != 202506" +#endif diff --git a/gcc/testsuite/g++.dg/reflect/feat3.C b/gcc/testsuite/g++.dg/reflect/feat3.C new file mode 100644 index 00000000000..68b72e27f39 --- /dev/null +++ b/gcc/testsuite/g++.dg/reflect/feat3.C @@ -0,0 +1,17 @@ +// { dg-do compile { target c++26 } } +// { dg-additional-options "-freflection" } +// Test feature test macros. + +#include + +#ifndef __cpp_lib_reflection +# error "__cpp_lib_reflection" +#elif __cpp_lib_reflection != 202506 +# error "__cpp_lib_reflection != 202506" +#endif + +#ifndef __cpp_lib_define_static +# error "__cpp_lib_define_static" +#elif __cpp_lib_define_static != 202506 +# error "__cpp_lib_define_static != 202506" +#endif diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index 8c5f4bb7c4c..ba0ef5aecfd 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -2271,6 +2271,16 @@ ftms = { }; }; +ftms = { + name = define_static; + values = { + v = 202506; + cxxmin = 26; + extra_cond = "__cpp_impl_reflection >= 202506L"; + cxx11abi = yes; + }; +}; + ftms = { name = is_implicit_lifetime; values = { diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index 985701447be..74d1a28f75c 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -2546,6 +2546,16 @@ #endif /* !defined(__cpp_lib_reflection) */ #undef __glibcxx_want_reflection +#if !defined(__cpp_lib_define_static) +# if (__cplusplus > 202302L) && _GLIBCXX_USE_CXX11_ABI && (__cpp_impl_reflection >= 202506L) +# define __glibcxx_define_static 202506L +# if defined(__glibcxx_want_all) || defined(__glibcxx_want_define_static) +# define __cpp_lib_define_static 202506L +# endif +# endif +#endif /* !defined(__cpp_lib_define_static) */ +#undef __glibcxx_want_define_static + #if !defined(__cpp_lib_is_implicit_lifetime) # if (__cplusplus >= 202100L) && (__has_builtin(__builtin_is_implicit_lifetime)) # define __glibcxx_is_implicit_lifetime 202302L diff --git a/libstdc++-v3/include/std/meta b/libstdc++-v3/include/std/meta index 033746a4034..59a678037a1 100644 --- a/libstdc++-v3/include/std/meta +++ b/libstdc++-v3/include/std/meta @@ -34,6 +34,7 @@ #endif #define __glibcxx_want_reflection +#define __glibcxx_want_define_static #include #if __glibcxx_reflection >= 202506L // C++ >= 26 && __cpp_impl_reflection