Hi! I've pushed "Fix templatized C++ OpenACC 'cache' directive ICEs" to master branch in commit 0cab70604cfda30bc64351b39493ef884ff7ba10, and backported to releases/gcc-10 branch in commit 5bfcc9e103c06d85de43766fe05eb59f4f50c3db, to releases/gcc-9 branch in commit 1cb1c9e62f92ad674976b0da8cc46d7350d79a05, to releases/gcc-8 branch in commit b4a3e26c329f63c9953f4c4e3141c562bf91ce93, see attached.
Grüße Thomas ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
>From 0cab70604cfda30bc64351b39493ef884ff7ba10 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tho...@codesourcery.com> Date: Wed, 25 Nov 2020 13:03:52 +0100 Subject: [PATCH] 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. --- gcc/cp/pt.c | 2 ++ gcc/testsuite/c-c++-common/goacc/cache-1.c | 18 +++++++++++------- gcc/testsuite/c-c++-common/goacc/cache-2.c | 10 +++++----- gcc/testsuite/g++.dg/goacc/cache-1.C | 15 +++++++++++++++ .../goacc/cache-2.c => g++.dg/goacc/cache-2.C} | 15 +++++++++++---- libgomp/testsuite/libgomp.oacc-c++/cache-1.C | 13 +++++++++++++ .../libgomp.oacc-c-c++-common/cache-1.c | 12 +++++++++++- 7 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 gcc/testsuite/g++.dg/goacc/cache-1.C copy gcc/testsuite/{c-c++-common/goacc/cache-2.c => g++.dg/goacc/cache-2.C} (90%) create mode 100644 libgomp/testsuite/libgomp.oacc-c++/cache-1.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index fdd7f2d457b..4fb0bc82c31 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 1d4759e738c..242f3c612fd 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 d1181d1b6e7..80b925e5112 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 00000000000..a8d5ab32016 --- /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/c-c++-common/goacc/cache-2.c b/gcc/testsuite/g++.dg/goacc/cache-2.C similarity index 90% copy from gcc/testsuite/c-c++-common/goacc/cache-2.c copy to gcc/testsuite/g++.dg/goacc/cache-2.C index d1181d1b6e7..ef0b8a9e76f 100644 --- a/gcc/testsuite/c-c++-common/goacc/cache-2.c +++ b/gcc/testsuite/g++.dg/goacc/cache-2.C @@ -1,7 +1,10 @@ -/* OpenACC cache directive: invalid usage. */ +/* OpenACC 'cache' directive: invalid usage. */ -int -main (int argc, char **argv) +/* 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]; @@ -52,6 +55,10 @@ main (int argc, char **argv) if (a[i] != b[i]) __builtin_abort (); } +} - return 0; +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 00000000000..fcb1f84eef9 --- /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 16aaed5df70..c0dddb3c4f3 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; +} -- 2.17.1
>From 5bfcc9e103c06d85de43766fe05eb59f4f50c3db Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tho...@codesourcery.com> Date: Wed, 25 Nov 2020 13:03:52 +0100 Subject: [PATCH] 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. (cherry picked from commit 0cab70604cfda30bc64351b39493ef884ff7ba10) --- gcc/cp/pt.c | 2 ++ gcc/testsuite/c-c++-common/goacc/cache-1.c | 18 +++++++++++------- gcc/testsuite/c-c++-common/goacc/cache-2.c | 10 +++++----- gcc/testsuite/g++.dg/goacc/cache-1.C | 15 +++++++++++++++ .../goacc/cache-2.c => g++.dg/goacc/cache-2.C} | 15 +++++++++++---- libgomp/testsuite/libgomp.oacc-c++/cache-1.C | 13 +++++++++++++ .../libgomp.oacc-c-c++-common/cache-1.c | 12 +++++++++++- 7 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 gcc/testsuite/g++.dg/goacc/cache-1.C copy gcc/testsuite/{c-c++-common/goacc/cache-2.c => g++.dg/goacc/cache-2.C} (90%) create mode 100644 libgomp/testsuite/libgomp.oacc-c++/cache-1.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index de7cbaa1d65..ecb6e7fef04 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17177,6 +17177,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: @@ -18654,6 +18655,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 1d4759e738c..242f3c612fd 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 d1181d1b6e7..80b925e5112 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 00000000000..a8d5ab32016 --- /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/c-c++-common/goacc/cache-2.c b/gcc/testsuite/g++.dg/goacc/cache-2.C similarity index 90% copy from gcc/testsuite/c-c++-common/goacc/cache-2.c copy to gcc/testsuite/g++.dg/goacc/cache-2.C index d1181d1b6e7..ef0b8a9e76f 100644 --- a/gcc/testsuite/c-c++-common/goacc/cache-2.c +++ b/gcc/testsuite/g++.dg/goacc/cache-2.C @@ -1,7 +1,10 @@ -/* OpenACC cache directive: invalid usage. */ +/* OpenACC 'cache' directive: invalid usage. */ -int -main (int argc, char **argv) +/* 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]; @@ -52,6 +55,10 @@ main (int argc, char **argv) if (a[i] != b[i]) __builtin_abort (); } +} - return 0; +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 00000000000..fcb1f84eef9 --- /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 16aaed5df70..c0dddb3c4f3 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; +} -- 2.17.1
>From 1cb1c9e62f92ad674976b0da8cc46d7350d79a05 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tho...@codesourcery.com> Date: Wed, 25 Nov 2020 13:03:52 +0100 Subject: [PATCH] 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. (cherry picked from commit 0cab70604cfda30bc64351b39493ef884ff7ba10) --- gcc/cp/pt.c | 2 ++ gcc/testsuite/c-c++-common/goacc/cache-1.c | 18 +++++++++++------- gcc/testsuite/c-c++-common/goacc/cache-2.c | 10 +++++----- gcc/testsuite/g++.dg/goacc/cache-1.C | 15 +++++++++++++++ .../goacc/cache-2.c => g++.dg/goacc/cache-2.C} | 15 +++++++++++---- libgomp/testsuite/libgomp.oacc-c++/cache-1.C | 13 +++++++++++++ .../libgomp.oacc-c-c++-common/cache-1.c | 12 +++++++++++- 7 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 gcc/testsuite/g++.dg/goacc/cache-1.C copy gcc/testsuite/{c-c++-common/goacc/cache-2.c => g++.dg/goacc/cache-2.C} (90%) create mode 100644 libgomp/testsuite/libgomp.oacc-c++/cache-1.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7f8138aa479..5116b0fe43d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -16455,6 +16455,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_IS_DEVICE_PTR: @@ -17898,6 +17899,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 1d4759e738c..242f3c612fd 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 d1181d1b6e7..80b925e5112 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 00000000000..a8d5ab32016 --- /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/c-c++-common/goacc/cache-2.c b/gcc/testsuite/g++.dg/goacc/cache-2.C similarity index 90% copy from gcc/testsuite/c-c++-common/goacc/cache-2.c copy to gcc/testsuite/g++.dg/goacc/cache-2.C index d1181d1b6e7..ef0b8a9e76f 100644 --- a/gcc/testsuite/c-c++-common/goacc/cache-2.c +++ b/gcc/testsuite/g++.dg/goacc/cache-2.C @@ -1,7 +1,10 @@ -/* OpenACC cache directive: invalid usage. */ +/* OpenACC 'cache' directive: invalid usage. */ -int -main (int argc, char **argv) +/* 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]; @@ -52,6 +55,10 @@ main (int argc, char **argv) if (a[i] != b[i]) __builtin_abort (); } +} - return 0; +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 00000000000..fcb1f84eef9 --- /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 16aaed5df70..c0dddb3c4f3 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; +} -- 2.17.1
>From b4a3e26c329f63c9953f4c4e3141c562bf91ce93 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tho...@codesourcery.com> Date: Wed, 25 Nov 2020 13:03:52 +0100 Subject: [PATCH] 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. (cherry picked from commit 0cab70604cfda30bc64351b39493ef884ff7ba10) --- gcc/cp/pt.c | 2 ++ gcc/testsuite/c-c++-common/goacc/cache-1.c | 18 +++++++++++------- gcc/testsuite/c-c++-common/goacc/cache-2.c | 10 +++++----- gcc/testsuite/g++.dg/goacc/cache-1.C | 15 +++++++++++++++ .../goacc/cache-2.c => g++.dg/goacc/cache-2.C} | 15 +++++++++++---- libgomp/testsuite/libgomp.oacc-c++/cache-1.C | 13 +++++++++++++ .../libgomp.oacc-c-c++-common/cache-1.c | 12 +++++++++++- 7 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 gcc/testsuite/g++.dg/goacc/cache-1.C copy gcc/testsuite/{c-c++-common/goacc/cache-2.c => g++.dg/goacc/cache-2.C} (90%) create mode 100644 libgomp/testsuite/libgomp.oacc-c++/cache-1.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2d38310f1fb..063b18c1f45 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -16130,6 +16130,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_USE_DEVICE_PTR: case OMP_CLAUSE_IS_DEVICE_PTR: OMP_CLAUSE_DECL (nc) @@ -17369,6 +17370,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 1d4759e738c..242f3c612fd 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 d1181d1b6e7..80b925e5112 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 00000000000..a8d5ab32016 --- /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/c-c++-common/goacc/cache-2.c b/gcc/testsuite/g++.dg/goacc/cache-2.C similarity index 90% copy from gcc/testsuite/c-c++-common/goacc/cache-2.c copy to gcc/testsuite/g++.dg/goacc/cache-2.C index d1181d1b6e7..ef0b8a9e76f 100644 --- a/gcc/testsuite/c-c++-common/goacc/cache-2.c +++ b/gcc/testsuite/g++.dg/goacc/cache-2.C @@ -1,7 +1,10 @@ -/* OpenACC cache directive: invalid usage. */ +/* OpenACC 'cache' directive: invalid usage. */ -int -main (int argc, char **argv) +/* 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]; @@ -52,6 +55,10 @@ main (int argc, char **argv) if (a[i] != b[i]) __builtin_abort (); } +} - return 0; +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 00000000000..fcb1f84eef9 --- /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 16aaed5df70..c0dddb3c4f3 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; +} -- 2.17.1