From 7f8bb6498691cace5cced224bfc72d13724c9b82 Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Wed, 15 Jan 2025 17:22:53 +0000 Subject: OpenMP: Improve error message for invalid directive in "assumes". gcc/c/ChangeLog * c-parser.cc (c_parser_omp_assumption_clauses): Give a more specific error message for invalid directives vs unknown names. gcc/cp/ChangeLog * parser.cc (cp_parser_omp_assumption_clauses): Give a more specific error message for invalid directives vs unknown names. gcc/fortran/ChangeLog * openmp.cc (gfc_omp_absent_contains_clause): Use an Oxford comma in the message. gcc/testsuite/ChangeLog * c-c++-common/gomp/assume-2.c: Adjust expected diagnostics. * c-c++-common/gomp/assumes-2.c: Likewise. * c-c++-common/gomp/begin-assumes-2.c: Likewise. * gfortran.dg/gomp/allocate-6.f90: Likewise. * gfortran.dg/gomp/assumes-2.f90: Likewise. --- gcc/c/c-parser.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'gcc/c/c-parser.cc') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index b45c7ef..f193329 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -28846,13 +28846,18 @@ c_parser_omp_assumption_clauses (c_parser *parser, bool is_assume) = c_omp_categorize_directive (directive[0], directive[1], directive[2]); - if (dir == NULL - || dir->kind == C_OMP_DIR_DECLARATIVE - || dir->kind == C_OMP_DIR_INFORMATIONAL - || dir->kind == C_OMP_DIR_META - || dir->id == PRAGMA_OMP_END - || (!dir->second && directive[1]) - || (!dir->third && directive[2])) + if (dir + && (dir->kind == C_OMP_DIR_DECLARATIVE + || dir->kind == C_OMP_DIR_INFORMATIONAL + || dir->kind == C_OMP_DIR_META)) + error_at (dloc, "invalid OpenMP directive name in " + "%qs clause argument: declarative, " + "informational, and meta directives " + "not permitted", p); + else if (dir == NULL + || dir->id == PRAGMA_OMP_END + || (!dir->second && directive[1]) + || (!dir->third && directive[2])) error_at (dloc, "unknown OpenMP directive name in " "%qs clause argument", p); else -- cgit v1.1