diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2020-11-25 13:03:52 +0100 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2020-11-25 19:57:39 +0100 |
commit | 0cab70604cfda30bc64351b39493ef884ff7ba10 (patch) | |
tree | c80b71b219a7be10a77e93166f87271ad0a1e1d0 | |
parent | 4919ed711c1d02845f2843f6b0a70c27f9e6d434 (diff) | |
download | gcc-0cab70604cfda30bc64351b39493ef884ff7ba10.zip gcc-0cab70604cfda30bc64351b39493ef884ff7ba10.tar.gz gcc-0cab70604cfda30bc64351b39493ef884ff7ba10.tar.bz2 |
Fix templatized C++ OpenACC 'cache' directive ICEs
This has been broken forever, whoops...
gcc/cp/
* pt.c (tsubst_omp_clauses): Handle 'OMP_CLAUSE__CACHE_'.
(tsubst_expr): Handle 'OACC_CACHE'.
gcc/testsuite/
* c-c++-common/goacc/cache-1.c: Update.
* c-c++-common/goacc/cache-2.c: Likewise.
* g++.dg/goacc/cache-1.C: New.
* g++.dg/goacc/cache-2.C: Likewise.
libgomp/
* testsuite/libgomp.oacc-c++/cache-1.C: New.
* testsuite/libgomp.oacc-c-c++-common/cache-1.c: Update.
-rw-r--r-- | gcc/cp/pt.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/goacc/cache-1.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/goacc/cache-2.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/goacc/cache-1.C | 15 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/goacc/cache-2.C | 64 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.oacc-c++/cache-1.C | 13 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.oacc-c-c++-common/cache-1.c | 12 |
7 files changed, 121 insertions, 13 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index fdd7f2d..4fb0bc8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17245,6 +17245,7 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort, case OMP_CLAUSE_FROM: case OMP_CLAUSE_TO: case OMP_CLAUSE_MAP: + case OMP_CLAUSE__CACHE_: case OMP_CLAUSE_NONTEMPORAL: case OMP_CLAUSE_USE_DEVICE_PTR: case OMP_CLAUSE_USE_DEVICE_ADDR: @@ -18761,6 +18762,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, add_stmt (t); break; + case OACC_CACHE: case OACC_ENTER_DATA: case OACC_EXIT_DATA: case OACC_UPDATE: diff --git a/gcc/testsuite/c-c++-common/goacc/cache-1.c b/gcc/testsuite/c-c++-common/goacc/cache-1.c index 1d4759e..242f3c6 100644 --- a/gcc/testsuite/c-c++-common/goacc/cache-1.c +++ b/gcc/testsuite/c-c++-common/goacc/cache-1.c @@ -1,9 +1,15 @@ -/* OpenACC cache directive: valid usage. */ -/* For execution testing, this file is "#include"d from - libgomp/testsuite/libgomp.oacc-c-c++-common/cache-1.c. */ +/* OpenACC 'cache' directive: valid usage. */ -int -main (int argc, char **argv) +/* See also corresponding C++ variant: '../../g++.dg/goacc/cache-1.C'. */ + +/* For execution testing, this file is '#include'd from + '../../../../libgomp/testsuite/libgomp.oacc-c-c++-common/cache-1.c'. */ + +#ifdef TEMPLATIZE +template <int N> +#endif +static void +test () { #define N 2 int a[N], b[N]; @@ -61,6 +67,4 @@ main (int argc, char **argv) if (a[i] != b[i]) __builtin_abort (); } - - return 0; } diff --git a/gcc/testsuite/c-c++-common/goacc/cache-2.c b/gcc/testsuite/c-c++-common/goacc/cache-2.c index d1181d1..80b925e 100644 --- a/gcc/testsuite/c-c++-common/goacc/cache-2.c +++ b/gcc/testsuite/c-c++-common/goacc/cache-2.c @@ -1,7 +1,9 @@ -/* OpenACC cache directive: invalid usage. */ +/* OpenACC 'cache' directive: invalid usage. */ -int -main (int argc, char **argv) +/* See also corresponding C++ variant: '../../g++.dg/goacc/cache-2.C'. */ + +static void +test () { #define N 2 int a[N], b[N]; @@ -52,6 +54,4 @@ main (int argc, char **argv) if (a[i] != b[i]) __builtin_abort (); } - - return 0; } diff --git a/gcc/testsuite/g++.dg/goacc/cache-1.C b/gcc/testsuite/g++.dg/goacc/cache-1.C new file mode 100644 index 0000000..a8d5ab3 --- /dev/null +++ b/gcc/testsuite/g++.dg/goacc/cache-1.C @@ -0,0 +1,15 @@ +/* OpenACC 'cache' directive: valid usage. */ + +/* See also corresponding C/C++ variant '../../c-c++-common/goacc/cache-1.c'. */ + +/* For execution testing, this file is '#include'd from + '../../../../libgomp/testsuite/libgomp.oacc-c++/cache-1.C'. */ + +#define TEMPLATIZE +#include "../../c-c++-common/goacc/cache-1.c" + +static void +instantiate () +{ + &test<0>; +} diff --git a/gcc/testsuite/g++.dg/goacc/cache-2.C b/gcc/testsuite/g++.dg/goacc/cache-2.C new file mode 100644 index 0000000..ef0b8a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/goacc/cache-2.C @@ -0,0 +1,64 @@ +/* OpenACC 'cache' directive: invalid usage. */ + +/* See also corresponding C/C++ variant '../../c-c++-common/goacc/cache-2.c'. */ + +template <int N> +static void +test () +{ +#define N 2 + int a[N], b[N]; + int i; + + for (i = 0; i < N; i++) + { + a[i] = 3; + b[i] = 0; + } + +#pragma acc parallel copyin (a[0:N]) copyout (b[0:N]) +{ + int ii; + + for (ii = 0; ii < N; ii++) + { + const int idx = ii; + int n = 1; + const int len = n; + +#pragma acc cache /* { dg-error "expected '\\\(' before end of line" } */ +#pragma acc cache a[0:N] /* { dg-error "expected '\\\(' before 'a'" } */ + /* { dg-bogus "expected end of line before 'a'" "" { xfail c++ } .-1 } */ +#pragma acc cache (a) /* { dg-error "expected '\\\['" } */ +#pragma acc cache ( /* { dg-error "expected (identifier|unqualified-id) before end of line" } */ +#pragma acc cache () /* { dg-error "expected (identifier|unqualified-id) before '\\\)' token" } */ +#pragma acc cache (,) /* { dg-error "expected (identifier|unqualified-id) before '(,|\\\))' token" } */ +#pragma acc cache (a[0:N] /* { dg-error "expected '\\\)' before end of line" } */ +#pragma acc cache (a[0:N],) /* { dg-error "expected (identifier|unqualified-id) before '(,|\\\))' token" "" { xfail c } } */ +#pragma acc cache (a[0:N]) copyin (a[0:N]) /* { dg-error "expected end of line before 'copyin'" } */ +#pragma acc cache () /* { dg-error "expected (identifier|unqualified-id) before '\\\)' token" } */ +#pragma acc cache (a[0:N] b[0:N]) /* { dg-error "expected '\\\)' before 'b'" } */ +#pragma acc cache (a[0:N] b[0:N}) /* { dg-error "expected '\\\)' before 'b'" } */ + /* { dg-bogus "expected end of line before '\\\}' token" "" { xfail c++ } .-1 } */ +#pragma acc cache (a[0:N] /* { dg-error "expected '\\\)' before end of line" } */ +#pragma acc cache (a[0:N]) ( /* { dg-error "expected end of line before '\\(' token" } */ +#pragma acc cache (a[0:N]) ii /* { dg-error "expected end of line before 'ii'" } */ +#pragma acc cache (a[0:N] ii) /* { dg-error "expected '\\)' before 'ii'" } */ + + b[ii] = a[ii]; + } +} + + + for (i = 0; i < N; i++) + { + if (a[i] != b[i]) + __builtin_abort (); + } +} + +static void +instantiate () +{ + &test<0>; +} diff --git a/libgomp/testsuite/libgomp.oacc-c++/cache-1.C b/libgomp/testsuite/libgomp.oacc-c++/cache-1.C new file mode 100644 index 0000000..fcb1f84 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c++/cache-1.C @@ -0,0 +1,13 @@ +/* OpenACC 'cache' directive. */ + +/* See also corresponding C/C++ variant '../libgomp.oacc-c-c++-common/cache-1.c'. */ + +#include "../../../gcc/testsuite/g++.dg/goacc/cache-1.C" + +int +main (int argc, char *argv[]) +{ + test<0> (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/cache-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/cache-1.c index 16aaed5..c0dddb3 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/cache-1.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/cache-1.c @@ -1,3 +1,13 @@ -/* OpenACC cache directive. */ +/* OpenACC 'cache' directive. */ + +/* See also corresponding C++ variant '../libgomp.oacc-c++/cache-1.C'. */ #include "../../../gcc/testsuite/c-c++-common/goacc/cache-1.c" + +int +main (int argc, char *argv[]) +{ + test (); + + return 0; +} |