[clang] [OpenACC] Improve C++20 compatibility of private/firstprivate test (PR #152233)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 6 10:24:37 PDT 2025
https://github.com/dgg5503 updated https://github.com/llvm/llvm-project/pull/152233
>From 922d56a0dbd371a49a542c0ffd4c943feb6764a1 Mon Sep 17 00:00:00 2001
From: Douglas Gliner <Douglas.Gliner at sony.com>
Date: Tue, 5 Aug 2025 17:40:49 -0700
Subject: [PATCH 1/2] [OpenACC] Improve C++20 compatibility of test
Under C++17, `DeletedCopy` and `DefaultedCopy` in the test
`clang/test/SemaOpenACC/private_firstprivate_reduction_required_ops.cpp` are
eligible for aggregate initialization. Under C++20 and up, that is no longer
the case. Therefore, an explicit constructor must be declared to avoid
additional diagnostics which the test does not expect.
This test was failing in our downstream testing where our toolchain uses C++20 as the
default dialect.
See this reduced example for more details: https://godbolt.org/z/46oErYT43
---
...ivate_firstprivate_reduction_required_ops.cpp | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/clang/test/SemaOpenACC/private_firstprivate_reduction_required_ops.cpp b/clang/test/SemaOpenACC/private_firstprivate_reduction_required_ops.cpp
index 4644bdeeacc0e..ae7ac33fb391f 100644
--- a/clang/test/SemaOpenACC/private_firstprivate_reduction_required_ops.cpp
+++ b/clang/test/SemaOpenACC/private_firstprivate_reduction_required_ops.cpp
@@ -37,10 +37,26 @@ struct ImplicitDelDtor {
};
struct DeletedCopy {
+#if __cplusplus >= 202002L
+ // C++20 performs value-initialization while previous language versions
+ // performed aggregate-initialization. This class is also not eligible for
+ // an implicit default constructor. Therefore, the constructor must be
+ // explicitly declared for value-initialization to avoid additional
+ // diagnostics.
+ DeletedCopy();
+#endif
DeletedCopy(const DeletedCopy&) = delete;
};
struct DefaultedCopy {
+#if __cplusplus >= 202002L
+ // C++20 performs value-initialization while previous language versions
+ // performed aggregate-initialization. This class is also not eligible for
+ // an implicit default constructor. Therefore, the constructor must be
+ // explicitly declared for value-initialization to avoid additional
+ // diagnostics.
+ DefaultedCopy();
+#endif
DefaultedCopy(const DefaultedCopy&) = default;
};
struct UserCopy {
>From 4b8ee5b7effd8aa5ed07a3debd21d72f26a45d81 Mon Sep 17 00:00:00 2001
From: Douglas <Douglas.Gliner at sony.com>
Date: Wed, 6 Aug 2025 10:20:43 -0700
Subject: [PATCH 2/2] Update private_firstprivate_reduction_required_ops.cpp
Remove ifdef + comment as suggested
---
...private_firstprivate_reduction_required_ops.cpp | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/clang/test/SemaOpenACC/private_firstprivate_reduction_required_ops.cpp b/clang/test/SemaOpenACC/private_firstprivate_reduction_required_ops.cpp
index ae7ac33fb391f..ce941ad4255da 100644
--- a/clang/test/SemaOpenACC/private_firstprivate_reduction_required_ops.cpp
+++ b/clang/test/SemaOpenACC/private_firstprivate_reduction_required_ops.cpp
@@ -37,26 +37,12 @@ struct ImplicitDelDtor {
};
struct DeletedCopy {
-#if __cplusplus >= 202002L
- // C++20 performs value-initialization while previous language versions
- // performed aggregate-initialization. This class is also not eligible for
- // an implicit default constructor. Therefore, the constructor must be
- // explicitly declared for value-initialization to avoid additional
- // diagnostics.
DeletedCopy();
-#endif
DeletedCopy(const DeletedCopy&) = delete;
};
struct DefaultedCopy {
-#if __cplusplus >= 202002L
- // C++20 performs value-initialization while previous language versions
- // performed aggregate-initialization. This class is also not eligible for
- // an implicit default constructor. Therefore, the constructor must be
- // explicitly declared for value-initialization to avoid additional
- // diagnostics.
DefaultedCopy();
-#endif
DefaultedCopy(const DefaultedCopy&) = default;
};
struct UserCopy {
More information about the cfe-commits
mailing list