From 1802f64e674eeef0c0d7e8f6ca2846145ec16315 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 24 Nov 2023 15:10:49 +0100 Subject: OpenMP: Accept argument to depobj's destroy clause Since OpenMP 5.2, the destroy clause takes an depend argument as argument; for the depobj directive, it the new argument is optional but, if present, it must be identical to the directive's argument. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_depobj): Accept optionally an argument to the destroy clause. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_depobj): Accept optionally an argument to the destroy clause. gcc/fortran/ChangeLog: * openmp.cc (gfc_match_omp_depobj): Accept optionally an argument to the destroy clause. libgomp/ChangeLog: * libgomp.texi (5.2 Impl. Status): An argument to the destroy clause is now supported. gcc/testsuite/ChangeLog: * c-c++-common/gomp/depobj-3.c: New test. * gfortran.dg/gomp/depobj-3.f90: New test. --- gcc/c/c-parser.cc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 371dd29..989c050 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -21605,6 +21605,9 @@ c_parser_omp_critical (location_t loc, c_parser *parser, bool *if_p) destroy update (dependence-type) + OpenMP 5.2 additionally: + destroy ( depobj ) + dependence-type: in out @@ -21663,7 +21666,26 @@ c_parser_omp_depobj (c_parser *parser) clause = error_mark_node; } else if (!strcmp ("destroy", p)) - kind = OMP_CLAUSE_DEPEND_LAST; + { + matching_parens c_parens; + kind = OMP_CLAUSE_DEPEND_LAST; + if (c_parser_next_token_is (parser, CPP_OPEN_PAREN) + && c_parens.require_open (parser)) + { + tree destobj = c_parser_expr_no_commas (parser, NULL).value; + if (!lvalue_p (destobj)) + error_at (EXPR_LOC_OR_LOC (destobj, c_loc), + "% expression is not lvalue expression"); + else if (depobj != error_mark_node + && !operand_equal_p (destobj, depobj, + OEP_MATCH_SIDE_EFFECTS + | OEP_LEXICOGRAPHIC)) + warning_at (EXPR_LOC_OR_LOC (destobj, c_loc), 0, + "the % expression %qE should be the same " + "as the % argument %qE", destobj, depobj); + c_parens.skip_until_found_close (parser); + } + } else if (!strcmp ("update", p)) { matching_parens c_parens; -- cgit v1.1