[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:20:52 PDT 2025
https://github.com/dgg5503 updated https://github.com/llvm/llvm-project/pull/152233
>From 099aa071081fa652ecebf40226c675617bb8d08a 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 d8ec38dfd7ced597a6641b02a9831f3db362d82a 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