mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
libstdc++: Fix up std::is_scalar for std::meta::info [PR125024]
https://eel.is/c++draft/basic.types.general#9.sentence-1 says that std::meta::info and its cv-qualified versions are scalar types too (and in https://eel.is/c++draft/basic.fundamental#19.sentence-1 that they are fundamental types too). Now, on the reflection side, eval_is_scalar_type is handled in the compiler and uses SCALAR_TYPE_P (type) which includes REFLECTION_TYPE_P check and eval_is_fundamental_type includes that explicitly too. std::is_fundamental uses template<typename _Tp> struct is_fundamental : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, is_null_pointer<_Tp> #if __cpp_impl_reflection >= 202506L , is_reflection<_Tp> #endif >::type { }; but for std::is_scalar we apparently forgot to include is_reflection. The following patch fixes that. 2026-04-26 Jakub Jelinek <jakub@redhat.com> PR libstdc++/125024 * include/std/type_traits (std::is_scalar): For __cpp_impl_reflection >= 202506L handle is_reflection types as scalar. * testsuite/20_util/is_scalar/reflection.cc: New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
This commit is contained in:
committed by
Jakub Jelinek
parent
a2d74fe9c9
commit
7f4cc8140e
@@ -871,7 +871,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
template<typename _Tp>
|
||||
struct is_scalar
|
||||
: public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
|
||||
is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
|
||||
is_member_pointer<_Tp>, is_null_pointer<_Tp>
|
||||
#if __cpp_impl_reflection >= 202506L
|
||||
, is_reflection<_Tp>
|
||||
#endif
|
||||
>::type
|
||||
{ };
|
||||
|
||||
/// is_compound
|
||||
|
||||
13
libstdc++-v3/testsuite/20_util/is_scalar/reflection.cc
Normal file
13
libstdc++-v3/testsuite/20_util/is_scalar/reflection.cc
Normal file
@@ -0,0 +1,13 @@
|
||||
// { dg-do compile { target c++26 } }
|
||||
// { dg-additional-options "-freflection" }
|
||||
|
||||
#include <type_traits>
|
||||
#include <testsuite_tr1.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
using std::is_scalar;
|
||||
using namespace __gnu_test;
|
||||
|
||||
static_assert(test_category<is_scalar, decltype (^^::)>(true), "");
|
||||
}
|
||||
Reference in New Issue
Block a user