[libcxx-commits] [libcxx] [libc++] Fix constexpr initialization of std::array<T, 0> (PR #74667)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 6 14:39:10 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 71be8f3c23497e28c86f1135f564b16106d8d6fb 1f37bb695a7ccc293d4793ff560cd45425c70960 -- libcxx/test/std/containers/sequences/array/size_and_alignment.compile.pass.cpp libcxx/include/array libcxx/test/std/containers/sequences/array/array.cons/initialization.pass.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/test/std/containers/sequences/array/array.cons/initialization.pass.cpp b/libcxx/test/std/containers/sequences/array/array.cons/initialization.pass.cpp
index bdc79e2201..ba7bea2cdc 100644
--- a/libcxx/test/std/containers/sequences/array/array.cons/initialization.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.cons/initialization.pass.cpp
@@ -20,16 +20,20 @@ struct NoDefault {
// Test default initialization
struct test_default_initialization {
- template <typename T>
- TEST_CONSTEXPR_CXX14 void operator()() const
- {
- std::array<T, 0> a0; (void)a0;
- std::array<T, 1> a1; (void)a1;
- std::array<T, 2> a2; (void)a2;
- std::array<T, 3> a3; (void)a3;
-
- std::array<NoDefault, 0> nodefault; (void)nodefault;
- }
+ template <typename T>
+ TEST_CONSTEXPR_CXX14 void operator()() const {
+ std::array<T, 0> a0;
+ (void)a0;
+ std::array<T, 1> a1;
+ (void)a1;
+ std::array<T, 2> a2;
+ (void)a2;
+ std::array<T, 3> a3;
+ (void)a3;
+
+ std::array<NoDefault, 0> nodefault;
+ (void)nodefault;
+ }
};
// Additional tests for constexpr default initialization of empty arrays since
@@ -38,12 +42,13 @@ struct test_default_initialization {
//
// Reproducer for https://github.com/llvm/llvm-project/issues/74375
struct test_default_initialization_74375 {
- template <typename T>
- TEST_CONSTEXPR_CXX14 void operator()() const
- {
- constexpr std::array<T, 0> a0; (void)a0;
- constexpr std::array<NoDefault, 0> nodefault; (void)nodefault;
- }
+ template <typename T>
+ TEST_CONSTEXPR_CXX14 void operator()() const {
+ constexpr std::array<T, 0> a0;
+ (void)a0;
+ constexpr std::array<NoDefault, 0> nodefault;
+ (void)nodefault;
+ }
};
struct test_nondefault_initialization {
@@ -194,9 +199,9 @@ int main(int, char**)
test_initializer_list();
#if TEST_STD_VER >= 14
static_assert(with_all_types<test_nondefault_initialization>(), "");
-#if TEST_STD_VER >= 20
+# if TEST_STD_VER >= 20
static_assert(with_all_types<test_default_initialization>(), "");
-#endif
+# endif
static_assert(with_all_types<test_default_initialization_74375>(), "");
static_assert(test_initializer_list(), "");
#endif
``````````
</details>
https://github.com/llvm/llvm-project/pull/74667
More information about the libcxx-commits
mailing list