summaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-04-08 09:39:43 +0200
committerTobias Burnus <tobias@codesourcery.com>2020-04-08 09:39:43 +0200
commit13e41d8b9d3d7598c72c38acc86a3d97046c8373 (patch)
tree90000a02958e8b0e36e120c7afcc9b6e839b4c04 /libgomp
parent38c3017f257484a6739e2fba821d95794f7f175c (diff)
[C/C++, OpenACC] Reject vars of different scope in acc declare (PR94120)
gcc/c/ PR middle-end/94120 * c-decl.c (c_check_in_current_scope): New function. * c-tree.h (c_check_in_current_scope): Declare it. * c-parser.c (c_parser_oacc_declare): Add check that variables are declared in the same scope as the directive. Fix handling of namespace vars. gcc/cp/ PR middle-end/94120 * paser.c (cp_parser_oacc_declare): Add check that variables are declared in the same scope as the directive. gcc/testsuite/ PR middle-end/94120 * c-c++-common/goacc/declare-pr94120.c: New. * g++.dg/declare-pr94120.C: New. libgomp/testsuite/ PR middle-end/94120 * libgomp.oacc-c++/declare-pr94120.C: New.
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog5
-rw-r--r--libgomp/testsuite/libgomp.oacc-c++/declare-pr94120.C57
2 files changed, 62 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 6f7327ab4a7..0e4958f0c67 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2020-04-08 Tobias Burnus <tobias@codesourcery.com>
+
+ PR middle-end/94120
+ * libgomp.oacc-c++/declare-pr94120.C: New.
+
2020-04-06 Maciej W. Rozycki <macro@wdc.com>
* configure.ac: Add testsuite/libgomp-site-extra.exp to output
diff --git a/libgomp/testsuite/libgomp.oacc-c++/declare-pr94120.C b/libgomp/testsuite/libgomp.oacc-c++/declare-pr94120.C
new file mode 100644
index 00000000000..1e1254187ea
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c++/declare-pr94120.C
@@ -0,0 +1,57 @@
+#include <openacc.h>
+#include <stdlib.h>
+
+#define N 8
+
+namespace one {
+ int A[N] = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ #pragma acc declare copyin (A)
+};
+
+namespace outer {
+ namespace inner {
+ int B[N];
+ #pragma acc declare create (B)
+ };
+};
+
+static void
+f (void)
+{
+ int i;
+ int C[N];
+ #pragma acc declare copyout (C)
+
+ if (!acc_is_present (&one::A, sizeof (one::A)))
+ abort ();
+
+ if (!acc_is_present (&outer::inner::B, sizeof (outer::inner::B)))
+ abort ();
+
+#pragma acc parallel
+ for (i = 0; i < N; i++)
+ {
+ outer::inner::B[i] = one::A[i];
+ C[i] = outer::inner::B[i];
+ }
+
+ for (i = 0; i < N; i++)
+ {
+ if (C[i] != i + 1)
+ abort ();
+ }
+
+#pragma acc parallel
+ for (i = 0; i < N; i++)
+ if (outer::inner::B[i] != i + 1)
+ abort ();
+}
+
+
+int
+main (int argc, char **argv)
+{
+ f ();
+
+ return 0;
+}