PR libgomp/96835
libgomp/
* testsuite/libgomp.c++/pr96835-1.C: New.
* testsuite/libgomp.c++/pr96835-1-O0.C: Likewise.
* testsuite/libgomp.oacc-c++/pr96835-1.C: Likewise.
---
libgomp/testsuite/libgomp.c++/pr96835-1-O0.C | 3 ++
libgomp/testsuite/libgomp.c++/pr96835-1.C | 45 +++++++++++++++++++
.../testsuite/libgomp.oacc-c++/pr96835-1.C | 6 +++
3 files changed, 54 insertions(+)
create mode 100644 libgomp/testsuite/libgomp.c++/pr96835-1-O0.C
create mode 100644 libgomp/testsuite/libgomp.c++/pr96835-1.C
create mode 100644 libgomp/testsuite/libgomp.oacc-c++/pr96835-1.C
diff --git a/libgomp/testsuite/libgomp.c++/pr96835-1-O0.C
b/libgomp/testsuite/libgomp.c++/pr96835-1-O0.C
new file mode 100644
index 000000000000..85e42909e29f
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr96835-1-O0.C
@@ -0,0 +1,3 @@
+// { dg-additional-options -O0 }
+
+#include "pr96835-1.C"
diff --git a/libgomp/testsuite/libgomp.c++/pr96835-1.C
b/libgomp/testsuite/libgomp.c++/pr96835-1.C
new file mode 100644
index 000000000000..c9f6475eeb91
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr96835-1.C
@@ -0,0 +1,45 @@
+// See also '../libgomp.oacc-c++/pr96835-1.C'.
+#ifndef ALWAYS_INLINE
+# define ALWAYS_INLINE
+#endif
+
+#pragma omp declare target
+
+template<int sz>
+struct vector {
+ int values_[sz];
+ vector();
+ ALWAYS_INLINE
+ vector(int const& init_val);
+ ALWAYS_INLINE
+ int dot(vector o) {
+ int res = 0;
+ for (int i = 0; i < sz; ++ i)
+ res += values_[i] * o.values_[i];
+ return res;
+ }
+};
+
+template<int sz>
+vector<sz>::vector(int const& init_val) {
+ for (int i = 0; i < sz; ++ i) values_[i] = init_val;
+}
+template<int sz>
+vector<sz>::vector() : vector(0) {
+}
+
+#pragma omp end declare target
+
+int main() {
+ int res = 0;
+ #pragma omp target map(from:res)
+ #pragma acc serial copyout(res)
+ {
+ vector<4> v1(1);
+ vector<4> v2(2);
+ res = v1.dot(v2);
+ }
+ if (res != 8)
+ __builtin_abort();
+ return 0;
+}
diff --git a/libgomp/testsuite/libgomp.oacc-c++/pr96835-1.C
b/libgomp/testsuite/libgomp.oacc-c++/pr96835-1.C
new file mode 100644
index 000000000000..0a6ee22ec3c9
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c++/pr96835-1.C
@@ -0,0 +1,6 @@
+// { dg-additional-options -fno-inline } for stable results regarding OpenACC
'routine'.
+// But actually, as none of the '#pragma acc routine' syntax is accepted (see
'../libgomp.c++/pr101544-1.C'), force inlining:
+#define ALWAYS_INLINE inline __attribute__((always_inline))
+
+#include "../libgomp.c++/pr96835-1.C"
+//TODO { dg-prune-output {using 'vector_length \(32\)', ignoring 1} }
--
2.34.1