From b94afd668d581fbdbc03104e156c0e528a6ef9ab Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 21 Jun 2017 22:22:05 +0000 Subject: PR c++/81154 * semantics.c (handle_omp_array_sections_1, finish_omp_clauses): Complain about t not being a variable if t is OVERLOAD even when processing_template_decl. * g++.dg/gomp/pr81154.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@249483 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 ++++ gcc/cp/semantics.c | 14 ++++----- gcc/testsuite/ChangeLog | 3 ++ gcc/testsuite/g++.dg/gomp/pr81154.C | 57 +++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/gomp/pr81154.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e9a5ec19a72..70ccf1d55e6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2017-06-21 Jakub Jelinek + PR c++/81154 + * semantics.c (handle_omp_array_sections_1, finish_omp_clauses): + Complain about t not being a variable if t is OVERLOAD even + when processing_template_decl. + Backported from mainline 2017-06-13 Jakub Jelinek diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index ca14be3ec52..ecfa4e25765 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4565,7 +4565,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, } if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL) { - if (processing_template_decl) + if (processing_template_decl && TREE_CODE (t) != OVERLOAD) return NULL_TREE; if (DECL_P (t)) error_at (OMP_CLAUSE_LOCATION (c), @@ -6079,7 +6079,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL && (!field_ok || TREE_CODE (t) != FIELD_DECL)) { - if (processing_template_decl) + if (processing_template_decl && TREE_CODE (t) != OVERLOAD) break; if (DECL_P (t)) error ("%qD is not a variable in clause %qs", t, @@ -6151,7 +6151,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) && ((ort & C_ORT_OMP_DECLARE_SIMD) != C_ORT_OMP || TREE_CODE (t) != FIELD_DECL)) { - if (processing_template_decl) + if (processing_template_decl && TREE_CODE (t) != OVERLOAD) break; if (DECL_P (t)) error ("%qD is not a variable in clause %", t); @@ -6194,7 +6194,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) && ((ort & C_ORT_OMP_DECLARE_SIMD) != C_ORT_OMP || TREE_CODE (t) != FIELD_DECL)) { - if (processing_template_decl) + if (processing_template_decl && TREE_CODE (t) != OVERLOAD) break; if (DECL_P (t)) error ("%qD is not a variable in clause %", t); @@ -6557,7 +6557,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) } if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL) { - if (processing_template_decl) + if (processing_template_decl && TREE_CODE (t) != OVERLOAD) break; if (DECL_P (t)) error ("%qD is not a variable in % clause", t); @@ -6639,7 +6639,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) remove = true; else if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL) { - if (processing_template_decl) + if (processing_template_decl && TREE_CODE (t) != OVERLOAD) break; if (DECL_P (t)) error ("%qD is not a variable in % clause", t); @@ -6770,7 +6770,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) } if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL) { - if (processing_template_decl) + if (processing_template_decl && TREE_CODE (t) != OVERLOAD) break; if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 32700ea2902..38f0ee50fb4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-06-21 Jakub Jelinek + PR c++/81154 + * g++.dg/gomp/pr81154.C: New test. + Backported from mainline 2017-06-20 Jakub Jelinek diff --git a/gcc/testsuite/g++.dg/gomp/pr81154.C b/gcc/testsuite/g++.dg/gomp/pr81154.C new file mode 100644 index 00000000000..dc0aec33e14 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr81154.C @@ -0,0 +1,57 @@ +// PR c++/81154 +// { dg-do compile } + +template +struct C +{ + int foo (T n) const + { +#pragma omp parallel shared (foo) // { dg-error "is not a variable in clause" } + ; +#pragma omp parallel private (foo) // { dg-error "is not a variable in clause" } + ; +#pragma omp parallel firstprivate (foo) // { dg-error "is not a variable in clause" } + ; +#pragma omp parallel for lastprivate (foo) // { dg-error "is not a variable in clause" } + for (T i = 0; i < n; i++) + ; +#pragma omp parallel for linear (foo) // { dg-error "is not a variable in clause" } + for (T i = 0; i < n; i++) + ; +#pragma omp parallel reduction (+:foo) // { dg-error "is not a variable in clause" } + ; + return 0; + } + int foo (int x, int y) { return x; } +}; + +struct D +{ + typedef int T; + int foo (T n) const + { +#pragma omp parallel shared (foo) // { dg-error "is not a variable in clause" } + ; +#pragma omp parallel private (foo) // { dg-error "is not a variable in clause" } + ; +#pragma omp parallel firstprivate (foo) // { dg-error "is not a variable in clause" } + ; +#pragma omp parallel for lastprivate (foo) // { dg-error "is not a variable in clause" } + for (T i = 0; i < n; i++) + ; +#pragma omp parallel for linear (foo) // { dg-error "is not a variable in clause" } + for (T i = 0; i < n; i++) + ; +#pragma omp parallel reduction (+:foo) // { dg-error "is not a variable in clause" } + ; + return 0; + } + int foo (int x, int y) { return x; } +}; + +int +main () +{ + C ().foo (1); + D ().foo (1); +} -- cgit v1.2.1