From: Jakub Jelinek Date: Sat, 16 Sep 2017 18:31:58 +0000 (+0200) Subject: backport: re PR c++/81154 (OpenMP with shared variable in a template class crash) X-Git-Tag: releases/gcc-5.5.0~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08e4e740608a55a4a875ee04d2556e8e15e57aaf;p=thirdparty%2Fgcc.git backport: re PR c++/81154 (OpenMP with shared variable in a template class crash) Backported from mainline 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. * g++.dg/gomp/pr81154.C: New test. From-SVN: r252878 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4db627a131d4..c3d0f47c840e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2017-09-16 Jakub Jelinek + + Backported from mainline + 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. + 2017-06-08 Jakub Jelinek PR c/81006 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index a2d07aa2722a..eb79696a5a8d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4297,7 +4297,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, return error_mark_node; if (TREE_CODE (t) != VAR_DECL && 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), @@ -5392,7 +5392,7 @@ finish_omp_clauses (tree clauses) t = OMP_CLAUSE_DECL (c); 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 %qs", t, @@ -5417,7 +5417,7 @@ finish_omp_clauses (tree clauses) t = OMP_CLAUSE_DECL (c); 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); @@ -5439,7 +5439,7 @@ finish_omp_clauses (tree clauses) t = OMP_CLAUSE_DECL (c); 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); @@ -5683,7 +5683,7 @@ finish_omp_clauses (tree clauses) t = OMP_CLAUSE_DECL (c); if (TREE_CODE (t) != VAR_DECL && 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); @@ -5753,7 +5753,7 @@ finish_omp_clauses (tree clauses) remove = true; else if (TREE_CODE (t) != VAR_DECL && 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); @@ -5795,7 +5795,7 @@ finish_omp_clauses (tree clauses) remove = true; else if (TREE_CODE (t) != VAR_DECL && 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 7c6425f679c8..02db110fe5e4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-09-16 Jakub Jelinek + + Backported from mainline + 2017-06-21 Jakub Jelinek + + PR c++/81154 + * g++.dg/gomp/pr81154.C: New test. + 2017-09-15 Martin Liska Backport from mainline diff --git a/gcc/testsuite/g++.dg/gomp/pr81154.C b/gcc/testsuite/g++.dg/gomp/pr81154.C new file mode 100644 index 000000000000..f6617dc71d17 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr81154.C @@ -0,0 +1,51 @@ +// 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 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 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); +}