[Mlir-commits] [clang-tools-extra] [clang] [llvm] [libcxx] [mlir] [libc++][concepts] Implements concept helper `__libcpp_integer` (PR #78086)
Hristo Hristov
llvmlistbot at llvm.org
Sun Jan 14 09:43:17 PST 2024
https://github.com/H-G-Hristov updated https://github.com/llvm/llvm-project/pull/78086
>From f2008de694bc867efa9632df183f64e3ea194e4e Mon Sep 17 00:00:00 2001
From: Zingam <zingam at outlook.com>
Date: Sun, 14 Jan 2024 09:34:46 +0200
Subject: [PATCH 1/5] [libc++][concepts] Implements concept helper
`__libcpp_integer`
...and tests.
---
libcxx/include/__concepts/arithmetic.h | 4 +
.../arithmetic.compile.pass.cpp | 117 ++++++++++++++++++
2 files changed, 121 insertions(+)
create mode 100644 libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp
diff --git a/libcxx/include/__concepts/arithmetic.h b/libcxx/include/__concepts/arithmetic.h
index f41e4c9f2747cc3..0c44f117805f368 100644
--- a/libcxx/include/__concepts/arithmetic.h
+++ b/libcxx/include/__concepts/arithmetic.h
@@ -42,9 +42,13 @@ concept floating_point = is_floating_point_v<_Tp>;
template <class _Tp>
concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value;
+
template <class _Tp>
concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value;
+template <class _Tp>
+concept __libcpp_integer = __libcpp_unsigned_integer<_Tp> || __libcpp_signed_integer<_Tp>;
+
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp
new file mode 100644
index 000000000000000..aefe21d852df52b
--- /dev/null
+++ b/libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+#include <concepts>
+
+struct SomeObject {};
+
+// Concept helpers for the internal type traits for the fundamental types.
+
+// template <class _Tp>
+// concept __libcpp_unsigned_integer;
+
+// Unsigned
+static_assert(std::__libcpp_unsigned_integer<unsigned char>);
+static_assert(std::__libcpp_unsigned_integer<unsigned short int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned long int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned long long int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(std::__libcpp_unsigned_integer<__uint128_t>);
+#endif
+// Signed
+static_assert(!std::__libcpp_unsigned_integer<signed char>);
+static_assert(!std::__libcpp_unsigned_integer<short int>);
+static_assert(!std::__libcpp_unsigned_integer<int>);
+static_assert(!std::__libcpp_unsigned_integer<long int>);
+static_assert(!std::__libcpp_unsigned_integer<long long int>);
+static_assert(!std::__libcpp_unsigned_integer<short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(!std::__libcpp_unsigned_integer<__int128_t>);
+#endif
+// Non-integer
+static_assert(!std::__libcpp_unsigned_integer<bool>);
+static_assert(!std::__libcpp_unsigned_integer<char8_t>);
+static_assert(!std::__libcpp_unsigned_integer<char16_t>);
+static_assert(!std::__libcpp_unsigned_integer<char32_t>);
+static_assert(!std::__libcpp_unsigned_integer<float>);
+static_assert(!std::__libcpp_unsigned_integer<double>);
+static_assert(!std::__libcpp_unsigned_integer<long double>);
+static_assert(!std::__libcpp_unsigned_integer<void>);
+static_assert(!std::__libcpp_unsigned_integer<SomeObject>);
+
+// template <class _Tp>
+// concept __libcpp_signed_integer;
+
+// Unsigned
+static_assert(!std::__libcpp_signed_integer<unsigned char>);
+static_assert(!std::__libcpp_signed_integer<unsigned short int>);
+static_assert(!std::__libcpp_signed_integer<unsigned int>);
+static_assert(!std::__libcpp_signed_integer<unsigned long int>);
+static_assert(!std::__libcpp_signed_integer<unsigned long long int>);
+static_assert(!std::__libcpp_signed_integer<unsigned short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(!std::__libcpp_signed_integer<__uint128_t>);
+#endif
+// Signed
+static_assert(std::__libcpp_signed_integer<signed char>);
+static_assert(std::__libcpp_signed_integer<short int>);
+static_assert(std::__libcpp_signed_integer<int>);
+static_assert(std::__libcpp_signed_integer<long int>);
+static_assert(std::__libcpp_signed_integer<long long int>);
+static_assert(std::__libcpp_signed_integer<short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(std::__libcpp_signed_integer<__int128_t>);
+#endif
+// Non-integer
+static_assert(!std::__libcpp_signed_integer<bool>);
+static_assert(!std::__libcpp_signed_integer<char8_t>);
+static_assert(!std::__libcpp_signed_integer<char16_t>);
+static_assert(!std::__libcpp_signed_integer<char32_t>);
+static_assert(!std::__libcpp_signed_integer<float>);
+static_assert(!std::__libcpp_signed_integer<double>);
+static_assert(!std::__libcpp_signed_integer<long double>);
+static_assert(!std::__libcpp_signed_integer<void>);
+static_assert(!std::__libcpp_signed_integer<SomeObject>);
+
+// template <class _Tp>
+// concept __libcpp_integer;
+
+// Unsigned
+static_assert(std::__libcpp_integer<unsigned char>);
+static_assert(std::__libcpp_integer<unsigned short int>);
+static_assert(std::__libcpp_integer<unsigned int>);
+static_assert(std::__libcpp_integer<unsigned long int>);
+static_assert(std::__libcpp_integer<unsigned long long int>);
+static_assert(std::__libcpp_integer<unsigned short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(std::__libcpp_integer<__uint128_t>);
+#endif
+// Signed
+static_assert(std::__libcpp_integer<signed char>);
+static_assert(std::__libcpp_integer<short int>);
+static_assert(std::__libcpp_integer<int>);
+static_assert(std::__libcpp_integer<long int>);
+static_assert(std::__libcpp_integer<long long int>);
+static_assert(std::__libcpp_integer<short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(std::__libcpp_integer<__int128_t>);
+#endif
+// Non-integer
+static_assert(!std::__libcpp_integer<bool>);
+static_assert(!std::__libcpp_integer<char8_t>);
+static_assert(!std::__libcpp_integer<char16_t>);
+static_assert(!std::__libcpp_integer<char32_t>);
+static_assert(!std::__libcpp_integer<float>);
+static_assert(!std::__libcpp_integer<double>);
+static_assert(!std::__libcpp_integer<long double>);
+static_assert(!std::__libcpp_integer<void>);
+static_assert(!std::__libcpp_integer<SomeObject>);
>From 62385a3da20d1fe0308ee6f31fbd3abce8aef97c Mon Sep 17 00:00:00 2001
From: Zingam <zingam at outlook.com>
Date: Sun, 14 Jan 2024 17:43:13 +0200
Subject: [PATCH 2/5] Addressed comments
---
.../arithmetic.compile.pass.cpp | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp
index aefe21d852df52b..68d33f3745b1cd3 100644
--- a/libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp
+++ b/libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp
@@ -10,8 +10,14 @@
#include <concepts>
+#include "test_macros.h"
+
struct SomeObject {};
+enum Enum {};
+
+enum class ScopedEnum {};
+
// Concept helpers for the internal type traits for the fundamental types.
// template <class _Tp>
@@ -39,6 +45,10 @@ static_assert(!std::__libcpp_unsigned_integer<__int128_t>);
#endif
// Non-integer
static_assert(!std::__libcpp_unsigned_integer<bool>);
+static_assert(!std::__libcpp_unsigned_integer<char>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!std::__libcpp_unsigned_integer<wchar_t>);
+#endif
static_assert(!std::__libcpp_unsigned_integer<char8_t>);
static_assert(!std::__libcpp_unsigned_integer<char16_t>);
static_assert(!std::__libcpp_unsigned_integer<char32_t>);
@@ -46,7 +56,10 @@ static_assert(!std::__libcpp_unsigned_integer<float>);
static_assert(!std::__libcpp_unsigned_integer<double>);
static_assert(!std::__libcpp_unsigned_integer<long double>);
static_assert(!std::__libcpp_unsigned_integer<void>);
+static_assert(!std::__libcpp_unsigned_integer<int*>);
static_assert(!std::__libcpp_unsigned_integer<SomeObject>);
+static_assert(!std::__libcpp_unsigned_integer<Enum>);
+static_assert(!std::__libcpp_unsigned_integer<ScopedEnum>);
// template <class _Tp>
// concept __libcpp_signed_integer;
@@ -73,6 +86,10 @@ static_assert(std::__libcpp_signed_integer<__int128_t>);
#endif
// Non-integer
static_assert(!std::__libcpp_signed_integer<bool>);
+static_assert(!std::__libcpp_signed_integer<char>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!std::__libcpp_signed_integer<wchar_t>);
+#endif
static_assert(!std::__libcpp_signed_integer<char8_t>);
static_assert(!std::__libcpp_signed_integer<char16_t>);
static_assert(!std::__libcpp_signed_integer<char32_t>);
@@ -80,7 +97,10 @@ static_assert(!std::__libcpp_signed_integer<float>);
static_assert(!std::__libcpp_signed_integer<double>);
static_assert(!std::__libcpp_signed_integer<long double>);
static_assert(!std::__libcpp_signed_integer<void>);
+static_assert(!std::__libcpp_signed_integer<int*>);
static_assert(!std::__libcpp_signed_integer<SomeObject>);
+static_assert(!std::__libcpp_signed_integer<Enum>);
+static_assert(!std::__libcpp_signed_integer<ScopedEnum>);
// template <class _Tp>
// concept __libcpp_integer;
@@ -107,6 +127,10 @@ static_assert(std::__libcpp_integer<__int128_t>);
#endif
// Non-integer
static_assert(!std::__libcpp_integer<bool>);
+static_assert(!std::__libcpp_integer<char>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!std::__libcpp_integer<wchar_t>);
+#endif
static_assert(!std::__libcpp_integer<char8_t>);
static_assert(!std::__libcpp_integer<char16_t>);
static_assert(!std::__libcpp_integer<char32_t>);
@@ -114,4 +138,7 @@ static_assert(!std::__libcpp_integer<float>);
static_assert(!std::__libcpp_integer<double>);
static_assert(!std::__libcpp_integer<long double>);
static_assert(!std::__libcpp_integer<void>);
+static_assert(!std::__libcpp_integer<int*>);
static_assert(!std::__libcpp_integer<SomeObject>);
+static_assert(!std::__libcpp_integer<Enum>);
+static_assert(!std::__libcpp_integer<ScopedEnum>);
>From 91eafc8f13daf842cfd5bf3a8b5eb1ea693b9746 Mon Sep 17 00:00:00 2001
From: Zingam <zingam at outlook.com>
Date: Sun, 14 Jan 2024 17:56:34 +0200
Subject: [PATCH 3/5] Split test
---
.../__libc_integer.compile.pass.cpp | 62 ++++++++
.../__libcpp_signed_integer..compile.pass.cpp | 62 ++++++++
...__libcpp_unsigned_integer.compile.pass.cpp | 62 ++++++++
.../arithmetic.compile.pass.cpp | 144 ------------------
4 files changed, 186 insertions(+), 144 deletions(-)
create mode 100644 libcxx/test/libcxx/concepts/concepts.arithmetic/__libc_integer.compile.pass.cpp
create mode 100644 libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer..compile.pass.cpp
create mode 100644 libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp
delete mode 100644 libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp
diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libc_integer.compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libc_integer.compile.pass.cpp
new file mode 100644
index 000000000000000..52fffb96456030a
--- /dev/null
+++ b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libc_integer.compile.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// Concept helpers for the internal type traits for the fundamental types.
+
+// template <class _Tp>
+// concept __libcpp_integer;
+
+#include <concepts>
+
+#include "test_macros.h"
+
+struct SomeObject {};
+
+enum SomeEnum {};
+
+enum class SomeScopedEnum {};
+
+// Unsigned
+static_assert(std::__libcpp_integer<unsigned char>);
+static_assert(std::__libcpp_integer<unsigned short int>);
+static_assert(std::__libcpp_integer<unsigned int>);
+static_assert(std::__libcpp_integer<unsigned long int>);
+static_assert(std::__libcpp_integer<unsigned long long int>);
+static_assert(std::__libcpp_integer<unsigned short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(std::__libcpp_integer<__uint128_t>);
+#endif
+// Signed
+static_assert(std::__libcpp_integer<signed char>);
+static_assert(std::__libcpp_integer<short int>);
+static_assert(std::__libcpp_integer<int>);
+static_assert(std::__libcpp_integer<long int>);
+static_assert(std::__libcpp_integer<long long int>);
+static_assert(std::__libcpp_integer<short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(std::__libcpp_integer<__int128_t>);
+#endif
+// Non-integer
+static_assert(!std::__libcpp_integer<bool>);
+static_assert(!std::__libcpp_integer<char>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!std::__libcpp_integer<wchar_t>);
+#endif
+static_assert(!std::__libcpp_integer<char8_t>);
+static_assert(!std::__libcpp_integer<char16_t>);
+static_assert(!std::__libcpp_integer<char32_t>);
+static_assert(!std::__libcpp_integer<float>);
+static_assert(!std::__libcpp_integer<double>);
+static_assert(!std::__libcpp_integer<long double>);
+static_assert(!std::__libcpp_integer<void>);
+static_assert(!std::__libcpp_integer<int*>);
+static_assert(!std::__libcpp_integer<SomeObject>);
+static_assert(!std::__libcpp_integer<SomeEnum>);
+static_assert(!std::__libcpp_integer<SomeScopedEnum>);
diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer..compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer..compile.pass.cpp
new file mode 100644
index 000000000000000..73ac2a7f53b83fe
--- /dev/null
+++ b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer..compile.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// Concept helpers for the internal type traits for the fundamental types.
+
+// template <class _Tp>
+// concept __libcpp_signed_integer;
+
+#include <concepts>
+
+#include "test_macros.h"
+
+struct SomeObject {};
+
+enum SomeEnum {};
+
+enum class SomeScopedEnum {};
+
+// Unsigned
+static_assert(!std::__libcpp_signed_integer<unsigned char>);
+static_assert(!std::__libcpp_signed_integer<unsigned short int>);
+static_assert(!std::__libcpp_signed_integer<unsigned int>);
+static_assert(!std::__libcpp_signed_integer<unsigned long int>);
+static_assert(!std::__libcpp_signed_integer<unsigned long long int>);
+static_assert(!std::__libcpp_signed_integer<unsigned short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(!std::__libcpp_signed_integer<__uint128_t>);
+#endif
+// Signed
+static_assert(std::__libcpp_signed_integer<signed char>);
+static_assert(std::__libcpp_signed_integer<short int>);
+static_assert(std::__libcpp_signed_integer<int>);
+static_assert(std::__libcpp_signed_integer<long int>);
+static_assert(std::__libcpp_signed_integer<long long int>);
+static_assert(std::__libcpp_signed_integer<short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(std::__libcpp_signed_integer<__int128_t>);
+#endif
+// Non-integer
+static_assert(!std::__libcpp_signed_integer<bool>);
+static_assert(!std::__libcpp_signed_integer<char>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!std::__libcpp_signed_integer<wchar_t>);
+#endif
+static_assert(!std::__libcpp_signed_integer<char8_t>);
+static_assert(!std::__libcpp_signed_integer<char16_t>);
+static_assert(!std::__libcpp_signed_integer<char32_t>);
+static_assert(!std::__libcpp_signed_integer<float>);
+static_assert(!std::__libcpp_signed_integer<double>);
+static_assert(!std::__libcpp_signed_integer<long double>);
+static_assert(!std::__libcpp_signed_integer<void>);
+static_assert(!std::__libcpp_signed_integer<int*>);
+static_assert(!std::__libcpp_signed_integer<SomeObject>);
+static_assert(!std::__libcpp_signed_integer<SomeEnum>);
+static_assert(!std::__libcpp_signed_integer<SomeScopedEnum>);
diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp
new file mode 100644
index 000000000000000..824349efcf82006
--- /dev/null
+++ b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// Concept helpers for the internal type traits for the fundamental types.
+
+// template <class _Tp>
+// concept __libcpp_unsigned_integer;
+
+#include <concepts>
+
+#include "test_macros.h"
+
+struct SomeObject {};
+
+enum SomeEnum {};
+
+enum class SomeScopedEnum {};
+
+// Unsigned
+static_assert(std::__libcpp_unsigned_integer<unsigned char>);
+static_assert(std::__libcpp_unsigned_integer<unsigned short int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned long int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned long long int>);
+static_assert(std::__libcpp_unsigned_integer<unsigned short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(std::__libcpp_unsigned_integer<__uint128_t>);
+#endif
+// Signed
+static_assert(!std::__libcpp_unsigned_integer<signed char>);
+static_assert(!std::__libcpp_unsigned_integer<short int>);
+static_assert(!std::__libcpp_unsigned_integer<int>);
+static_assert(!std::__libcpp_unsigned_integer<long int>);
+static_assert(!std::__libcpp_unsigned_integer<long long int>);
+static_assert(!std::__libcpp_unsigned_integer<short int>);
+#ifndef _LIBCPP_HAS_NO_INT128
+static_assert(!std::__libcpp_unsigned_integer<__int128_t>);
+#endif
+// Non-integer
+static_assert(!std::__libcpp_unsigned_integer<bool>);
+static_assert(!std::__libcpp_unsigned_integer<char>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!std::__libcpp_unsigned_integer<wchar_t>);
+#endif
+static_assert(!std::__libcpp_unsigned_integer<char8_t>);
+static_assert(!std::__libcpp_unsigned_integer<char16_t>);
+static_assert(!std::__libcpp_unsigned_integer<char32_t>);
+static_assert(!std::__libcpp_unsigned_integer<float>);
+static_assert(!std::__libcpp_unsigned_integer<double>);
+static_assert(!std::__libcpp_unsigned_integer<long double>);
+static_assert(!std::__libcpp_unsigned_integer<void>);
+static_assert(!std::__libcpp_unsigned_integer<int*>);
+static_assert(!std::__libcpp_unsigned_integer<SomeObject>);
+static_assert(!std::__libcpp_unsigned_integer<SomeEnum>);
+static_assert(!std::__libcpp_unsigned_integer<SomeScopedEnum>);
diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp
deleted file mode 100644
index 68d33f3745b1cd3..000000000000000
--- a/libcxx/test/libcxx/concepts/concepts.arithmetic/arithmetic.compile.pass.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++03, c++11, c++14, c++17
-
-#include <concepts>
-
-#include "test_macros.h"
-
-struct SomeObject {};
-
-enum Enum {};
-
-enum class ScopedEnum {};
-
-// Concept helpers for the internal type traits for the fundamental types.
-
-// template <class _Tp>
-// concept __libcpp_unsigned_integer;
-
-// Unsigned
-static_assert(std::__libcpp_unsigned_integer<unsigned char>);
-static_assert(std::__libcpp_unsigned_integer<unsigned short int>);
-static_assert(std::__libcpp_unsigned_integer<unsigned int>);
-static_assert(std::__libcpp_unsigned_integer<unsigned long int>);
-static_assert(std::__libcpp_unsigned_integer<unsigned long long int>);
-static_assert(std::__libcpp_unsigned_integer<unsigned short int>);
-#ifndef _LIBCPP_HAS_NO_INT128
-static_assert(std::__libcpp_unsigned_integer<__uint128_t>);
-#endif
-// Signed
-static_assert(!std::__libcpp_unsigned_integer<signed char>);
-static_assert(!std::__libcpp_unsigned_integer<short int>);
-static_assert(!std::__libcpp_unsigned_integer<int>);
-static_assert(!std::__libcpp_unsigned_integer<long int>);
-static_assert(!std::__libcpp_unsigned_integer<long long int>);
-static_assert(!std::__libcpp_unsigned_integer<short int>);
-#ifndef _LIBCPP_HAS_NO_INT128
-static_assert(!std::__libcpp_unsigned_integer<__int128_t>);
-#endif
-// Non-integer
-static_assert(!std::__libcpp_unsigned_integer<bool>);
-static_assert(!std::__libcpp_unsigned_integer<char>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!std::__libcpp_unsigned_integer<wchar_t>);
-#endif
-static_assert(!std::__libcpp_unsigned_integer<char8_t>);
-static_assert(!std::__libcpp_unsigned_integer<char16_t>);
-static_assert(!std::__libcpp_unsigned_integer<char32_t>);
-static_assert(!std::__libcpp_unsigned_integer<float>);
-static_assert(!std::__libcpp_unsigned_integer<double>);
-static_assert(!std::__libcpp_unsigned_integer<long double>);
-static_assert(!std::__libcpp_unsigned_integer<void>);
-static_assert(!std::__libcpp_unsigned_integer<int*>);
-static_assert(!std::__libcpp_unsigned_integer<SomeObject>);
-static_assert(!std::__libcpp_unsigned_integer<Enum>);
-static_assert(!std::__libcpp_unsigned_integer<ScopedEnum>);
-
-// template <class _Tp>
-// concept __libcpp_signed_integer;
-
-// Unsigned
-static_assert(!std::__libcpp_signed_integer<unsigned char>);
-static_assert(!std::__libcpp_signed_integer<unsigned short int>);
-static_assert(!std::__libcpp_signed_integer<unsigned int>);
-static_assert(!std::__libcpp_signed_integer<unsigned long int>);
-static_assert(!std::__libcpp_signed_integer<unsigned long long int>);
-static_assert(!std::__libcpp_signed_integer<unsigned short int>);
-#ifndef _LIBCPP_HAS_NO_INT128
-static_assert(!std::__libcpp_signed_integer<__uint128_t>);
-#endif
-// Signed
-static_assert(std::__libcpp_signed_integer<signed char>);
-static_assert(std::__libcpp_signed_integer<short int>);
-static_assert(std::__libcpp_signed_integer<int>);
-static_assert(std::__libcpp_signed_integer<long int>);
-static_assert(std::__libcpp_signed_integer<long long int>);
-static_assert(std::__libcpp_signed_integer<short int>);
-#ifndef _LIBCPP_HAS_NO_INT128
-static_assert(std::__libcpp_signed_integer<__int128_t>);
-#endif
-// Non-integer
-static_assert(!std::__libcpp_signed_integer<bool>);
-static_assert(!std::__libcpp_signed_integer<char>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!std::__libcpp_signed_integer<wchar_t>);
-#endif
-static_assert(!std::__libcpp_signed_integer<char8_t>);
-static_assert(!std::__libcpp_signed_integer<char16_t>);
-static_assert(!std::__libcpp_signed_integer<char32_t>);
-static_assert(!std::__libcpp_signed_integer<float>);
-static_assert(!std::__libcpp_signed_integer<double>);
-static_assert(!std::__libcpp_signed_integer<long double>);
-static_assert(!std::__libcpp_signed_integer<void>);
-static_assert(!std::__libcpp_signed_integer<int*>);
-static_assert(!std::__libcpp_signed_integer<SomeObject>);
-static_assert(!std::__libcpp_signed_integer<Enum>);
-static_assert(!std::__libcpp_signed_integer<ScopedEnum>);
-
-// template <class _Tp>
-// concept __libcpp_integer;
-
-// Unsigned
-static_assert(std::__libcpp_integer<unsigned char>);
-static_assert(std::__libcpp_integer<unsigned short int>);
-static_assert(std::__libcpp_integer<unsigned int>);
-static_assert(std::__libcpp_integer<unsigned long int>);
-static_assert(std::__libcpp_integer<unsigned long long int>);
-static_assert(std::__libcpp_integer<unsigned short int>);
-#ifndef _LIBCPP_HAS_NO_INT128
-static_assert(std::__libcpp_integer<__uint128_t>);
-#endif
-// Signed
-static_assert(std::__libcpp_integer<signed char>);
-static_assert(std::__libcpp_integer<short int>);
-static_assert(std::__libcpp_integer<int>);
-static_assert(std::__libcpp_integer<long int>);
-static_assert(std::__libcpp_integer<long long int>);
-static_assert(std::__libcpp_integer<short int>);
-#ifndef _LIBCPP_HAS_NO_INT128
-static_assert(std::__libcpp_integer<__int128_t>);
-#endif
-// Non-integer
-static_assert(!std::__libcpp_integer<bool>);
-static_assert(!std::__libcpp_integer<char>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!std::__libcpp_integer<wchar_t>);
-#endif
-static_assert(!std::__libcpp_integer<char8_t>);
-static_assert(!std::__libcpp_integer<char16_t>);
-static_assert(!std::__libcpp_integer<char32_t>);
-static_assert(!std::__libcpp_integer<float>);
-static_assert(!std::__libcpp_integer<double>);
-static_assert(!std::__libcpp_integer<long double>);
-static_assert(!std::__libcpp_integer<void>);
-static_assert(!std::__libcpp_integer<int*>);
-static_assert(!std::__libcpp_integer<SomeObject>);
-static_assert(!std::__libcpp_integer<Enum>);
-static_assert(!std::__libcpp_integer<ScopedEnum>);
>From 576458b49b5984410066ad00085488d2fb845ec5 Mon Sep 17 00:00:00 2001
From: Zingam <zingam at outlook.com>
Date: Sun, 14 Jan 2024 17:58:48 +0200
Subject: [PATCH 4/5] Name tweak
---
...integer.compile.pass.cpp => __libcpp_integer.compile.pass.cpp} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename libcxx/test/libcxx/concepts/concepts.arithmetic/{__libc_integer.compile.pass.cpp => __libcpp_integer.compile.pass.cpp} (100%)
diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libc_integer.compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp
similarity index 100%
rename from libcxx/test/libcxx/concepts/concepts.arithmetic/__libc_integer.compile.pass.cpp
rename to libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp
>From c14139bb5e730fa9072be98790d6a0798e19d6d6 Mon Sep 17 00:00:00 2001
From: Zingam <zingam at outlook.com>
Date: Sun, 14 Jan 2024 18:05:23 +0200
Subject: [PATCH 5/5] Tweaks and fixes
---
.../concepts.arithmetic/__libcpp_integer.compile.pass.cpp | 1 +
...compile.pass.cpp => __libcpp_signed_integer.compile.pass.cpp} | 1 +
.../__libcpp_unsigned_integer.compile.pass.cpp | 1 +
3 files changed, 3 insertions(+)
rename libcxx/test/libcxx/concepts/concepts.arithmetic/{__libcpp_signed_integer..compile.pass.cpp => __libcpp_signed_integer.compile.pass.cpp} (97%)
diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp
index 52fffb96456030a..55b5929847748fc 100644
--- a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp
+++ b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp
@@ -57,6 +57,7 @@ static_assert(!std::__libcpp_integer<double>);
static_assert(!std::__libcpp_integer<long double>);
static_assert(!std::__libcpp_integer<void>);
static_assert(!std::__libcpp_integer<int*>);
+static_assert(!std::__libcpp_integer<unsigned int*>);
static_assert(!std::__libcpp_integer<SomeObject>);
static_assert(!std::__libcpp_integer<SomeEnum>);
static_assert(!std::__libcpp_integer<SomeScopedEnum>);
diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer..compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer.compile.pass.cpp
similarity index 97%
rename from libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer..compile.pass.cpp
rename to libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer.compile.pass.cpp
index 73ac2a7f53b83fe..5bf7aa526f0a26f 100644
--- a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer..compile.pass.cpp
+++ b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer.compile.pass.cpp
@@ -57,6 +57,7 @@ static_assert(!std::__libcpp_signed_integer<double>);
static_assert(!std::__libcpp_signed_integer<long double>);
static_assert(!std::__libcpp_signed_integer<void>);
static_assert(!std::__libcpp_signed_integer<int*>);
+static_assert(!std::__libcpp_signed_integer<unsigned int*>);
static_assert(!std::__libcpp_signed_integer<SomeObject>);
static_assert(!std::__libcpp_signed_integer<SomeEnum>);
static_assert(!std::__libcpp_signed_integer<SomeScopedEnum>);
diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp
index 824349efcf82006..163ec53e17bc1e4 100644
--- a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp
+++ b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp
@@ -57,6 +57,7 @@ static_assert(!std::__libcpp_unsigned_integer<double>);
static_assert(!std::__libcpp_unsigned_integer<long double>);
static_assert(!std::__libcpp_unsigned_integer<void>);
static_assert(!std::__libcpp_unsigned_integer<int*>);
+static_assert(!std::__libcpp_unsigned_integer<unsigned int*>);
static_assert(!std::__libcpp_unsigned_integer<SomeObject>);
static_assert(!std::__libcpp_unsigned_integer<SomeEnum>);
static_assert(!std::__libcpp_unsigned_integer<SomeScopedEnum>);
More information about the Mlir-commits
mailing list