aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-07-21 18:29:53 +0200
committerTobias Burnus <tobias@codesourcery.com>2020-07-22 09:57:15 +0200
commitc7c24828cfa4983ebc6744be3f913d0da6ff7163 (patch)
treea8de602e795da9f5bac1ff2dcc94a1a4fd016876 /gcc/c-family
parentfb1de6a8543f4d7a63149bf99b54037315b8c3bb (diff)
downloadgcc-c7c24828cfa4983ebc6744be3f913d0da6ff7163.zip
gcc-c7c24828cfa4983ebc6744be3f913d0da6ff7163.tar.gz
gcc-c7c24828cfa4983ebc6744be3f913d0da6ff7163.tar.bz2
OpenMP: Fixes for omp critical + hint
gcc/c-family/ChangeLog: * c-omp.c (c_finish_omp_critical): Check for no name but nonzero hint provided. gcc/c/ChangeLog: * c-parser.c (c_parser_omp_clause_hint): Require nonnegative hint clause. (c_parser_omp_critical): Permit hint(0) clause without named critical. (c_parser_omp_construct): Don't assert if error_mark_node is returned. gcc/cp/ChangeLog: * parser.c (cp_parser_omp_clause_hint): Require nonnegative hint. (cp_parser_omp_critical): Permit hint(0) clause without named critical. * pt.c (tsubst_expr): Re-check the latter for templates. gcc/fortran/ChangeLog: * openmp.c (gfc_match_omp_critical): Fix handling hints; permit hint clause without named critical. (resolve_omp_clauses): Require nonnegative constant integer for the hint clause. (gfc_resolve_omp_directive): Check for no name but nonzero value for hint clause. * parse.c (parse_omp_structured_block): Fix same-name check for critical. * trans-openmp.c (gfc_trans_omp_critical): Handle hint clause properly. libgomp/ChangeLog: * omp_lib.f90.in: Add omp_sync_hint_* and omp_sync_hint_kind. * omp_lib.h.in: Likewise. gcc/testsuite/ChangeLog: * g++.dg/gomp/critical-3.C: Add nameless critical with hint testcase. * c-c++-common/gomp/critical-hint-1.c: New test. * c-c++-common/gomp/critical-hint-2.c: New test. * gfortran.dg/gomp/critical-hint-1.f90: New test. * gfortran.dg/gomp/critical-hint-2.f90: New test.
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-omp.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index 1ca2802..d7cff0f 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -106,6 +106,17 @@ c_finish_omp_taskgroup (location_t loc, tree body, tree clauses)
tree
c_finish_omp_critical (location_t loc, tree body, tree name, tree clauses)
{
+ gcc_assert (!clauses || OMP_CLAUSE_CODE (clauses) == OMP_CLAUSE_HINT);
+ if (name == NULL_TREE
+ && clauses != NULL_TREE
+ && integer_nonzerop (OMP_CLAUSE_HINT_EXPR (clauses)))
+ {
+ error_at (OMP_CLAUSE_LOCATION (clauses),
+ "%<#pragma omp critical%> with %<hint%> clause requires "
+ "a name, except when %<omp_sync_hint_none%> is used");
+ return error_mark_node;
+ }
+
tree stmt = make_node (OMP_CRITICAL);
TREE_TYPE (stmt) = void_type_node;
OMP_CRITICAL_BODY (stmt) = body;