]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
OpenMP: Update directive arrays used for 'omp assume(s)' with contains/absent
authorTobias Burnus <tburnus@baylibre.com>
Tue, 21 Oct 2025 11:31:19 +0000 (13:31 +0200)
committerTobias Burnus <tburnus@baylibre.com>
Tue, 21 Oct 2025 11:31:19 +0000 (13:31 +0200)
Both Fortran and C/C++ have an array with classifications of directives;
currently, this array is only used to handle the restrictions of the
contains/absent clauses to the assume/assumes directives.

For C/C++, uncommenting 'declare mapper' was missed. Additionally,
'end ...' is a directive but not a directive name; hence, those
are now rejected as 'unknown directive' instead of as 'invalid'
directive.

Additionally, both lists now list newer entries (commented out) for
OpenMP 6.x - and a note (comment) was added for C/C++'s
'begin metadirective' and for Fortran's 'allocate', respectively.

gcc/c-family/ChangeLog:

* c-omp.cc (c_omp_directives): Uncomment 'declare mapper',
add comment to 'begin metadirective', add 6.x unimplemented
directives as comment-out entries.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_assumption_clauses): Switch to
'unknown' not 'invalid' directive name for end directives.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_assumption_clauses): Switch to
'unknown' not 'invalid' directive name for end directives.

gcc/fortran/ChangeLog:

* openmp.cc (gfc_omp_directive): Add comment to 'allocate';
add 6.x unimplemented directives as comment-out entries.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/assumes-2.c: Change for 'invalid'
to 'unknown' change for end directives.
* c-c++-common/gomp/begin-assumes-2.c: Likewise.
* c-c++-common/gomp/assume-2.c: Likewise. Check 'declare
mapper'.

gcc/c-family/c-omp.cc
gcc/c/c-parser.cc
gcc/cp/parser.cc
gcc/fortran/openmp.cc
gcc/testsuite/c-c++-common/gomp/assume-2.c
gcc/testsuite/c-c++-common/gomp/assumes-2.c
gcc/testsuite/c-c++-common/gomp/begin-assumes-2.c

index fe272888c51e4f478adf98ba9823bacd97787dd3..3c2ee9ff1ae6bfc5f4a4010c9c8df08c6bb26658 100644 (file)
@@ -4604,6 +4604,9 @@ const struct c_omp_directive c_omp_directives[] = {
     C_OMP_DIR_DECLARATIVE, false },
   /* { "begin", "declare", "variant", PRAGMA_OMP_BEGIN,
     C_OMP_DIR_DECLARATIVE, false }, */
+  /* 'begin metadirective' is not yet implemented; however,
+     it is only applicable if an end-directive exists, but
+     metadirectives are of limited use for declarative directives.  */
   /* { "begin", "metadirective", nullptr, PRAGMA_OMP_BEGIN,
     C_OMP_DIR_META, false },  */
   { "cancel", nullptr, nullptr, PRAGMA_OMP_CANCEL,
@@ -4612,8 +4615,10 @@ const struct c_omp_directive c_omp_directives[] = {
     C_OMP_DIR_STANDALONE, false },
   { "critical", nullptr, nullptr, PRAGMA_OMP_CRITICAL,
     C_OMP_DIR_CONSTRUCT, false },
-  /* { "declare", "mapper", nullptr, PRAGMA_OMP_DECLARE,
-    C_OMP_DIR_DECLARATIVE, false },  */
+  /* { "declare", "induction", nullptr, PRAGMA_OMP_DECLARE,
+    C_OMP_DIR_DECLARATIVE, true }, */
+  { "declare", "mapper", nullptr, PRAGMA_OMP_DECLARE,
+    C_OMP_DIR_DECLARATIVE, false },
   { "declare", "reduction", nullptr, PRAGMA_OMP_DECLARE,
     C_OMP_DIR_DECLARATIVE, true },
   { "declare", "simd", nullptr, PRAGMA_OMP_DECLARE,
@@ -4639,12 +4644,18 @@ const struct c_omp_directive c_omp_directives[] = {
   /* error with at(execution) is C_OMP_DIR_STANDALONE.  */
   { "error", nullptr, nullptr, PRAGMA_OMP_ERROR,
     C_OMP_DIR_UTILITY, false },
+  /* { "flatten", nullptr, nullptr, PRAGMA_OMP_FLATTEN,
+    C_OMP_DIR_CONSTRUCT, true },  */
   { "flush", nullptr, nullptr, PRAGMA_OMP_FLUSH,
     C_OMP_DIR_STANDALONE, false },
   { "for", nullptr, nullptr, PRAGMA_OMP_FOR,
     C_OMP_DIR_CONSTRUCT, true },
+  /* { "fuse", nullptr, nullptr, PRAGMA_OMP_FUSE,
+    C_OMP_DIR_CONSTRUCT, true },  */
   /* { "groupprivate", nullptr, nullptr, PRAGMA_OMP_GROUPPRIVATE,
     C_OMP_DIR_DECLARATIVE, false },  */
+  /* { "interchange", nullptr, nullptr, PRAGMA_OMP_INTERCHANGE,
+    C_OMP_DIR_CONSTRUCT, true },  */
   { "interop", nullptr, nullptr, PRAGMA_OMP_INTEROP,
     C_OMP_DIR_STANDALONE, false },
   { "loop", nullptr, nullptr, PRAGMA_OMP_LOOP,
@@ -4676,6 +4687,10 @@ const struct c_omp_directive c_omp_directives[] = {
     C_OMP_DIR_CONSTRUCT, true },
   { "single", nullptr, nullptr, PRAGMA_OMP_SINGLE,
     C_OMP_DIR_CONSTRUCT, false },
+  /* { "split", nullptr, nullptr, PRAGMA_OMP_SPLIT,
+    C_OMP_DIR_CONSTRUCT, true },  */
+  /* { "stripe", nullptr, nullptr, PRAGMA_OMP_STRIPE,
+    C_OMP_DIR_CONSTRUCT, true },  */
   { "target", "data", nullptr, PRAGMA_OMP_TARGET,
     C_OMP_DIR_CONSTRUCT, false },
   { "target", "enter", "data", PRAGMA_OMP_TARGET,
@@ -4688,6 +4703,10 @@ const struct c_omp_directive c_omp_directives[] = {
     C_OMP_DIR_CONSTRUCT, true },
   { "task", nullptr, nullptr, PRAGMA_OMP_TASK,
     C_OMP_DIR_CONSTRUCT, false },
+  /* { "task", "iteration", nullptr, PRAGMA_OMP_TASK_ITERATION,
+    C_OMP_DIR_STANDALONE, false },  */
+  /* { "taskgraph", nullptr, nullptr, PRAGMA_OMP_TASKGRAPH,
+    C_OMP_DIR_CONSTRUCT, false },  */
   { "taskgroup", nullptr, nullptr, PRAGMA_OMP_TASKGROUP,
     C_OMP_DIR_CONSTRUCT, false },
   { "taskloop", nullptr, nullptr, PRAGMA_OMP_TASKLOOP,
index ea0294f0738e0a707bcae0b972cfcafd3ade5a55..dfee421165a7b9af44046d7ba37dd39ba3d0dd54 100644 (file)
@@ -29480,6 +29480,7 @@ c_parser_omp_assumption_clauses (c_parser *parser, bool is_assume)
                                                      directive[1],
                                                      directive[2]);
                      if (dir
+                         && dir->id != PRAGMA_OMP_END
                          && (dir->kind == C_OMP_DIR_DECLARATIVE
                              || dir->kind == C_OMP_DIR_INFORMATIONAL
                              || dir->kind == C_OMP_DIR_META))
index 9280632d47b84a93ed5b08377cc3242f98d3ea2c..e5d5d92cb8e2bc275a88a94a3cca8326926feffe 100644 (file)
@@ -51233,6 +51233,7 @@ cp_parser_omp_assumption_clauses (cp_parser *parser, cp_token *pragma_tok,
                                                      directive[1],
                                                      directive[2]);
                      if (dir
+                         && dir->id != PRAGMA_OMP_END
                          && (dir->kind == C_OMP_DIR_DECLARATIVE
                              || dir->kind == C_OMP_DIR_INFORMATIONAL
                              || dir->kind == C_OMP_DIR_META))
@@ -51241,9 +51242,9 @@ cp_parser_omp_assumption_clauses (cp_parser *parser, cp_token *pragma_tok,
                                        "informational, and meta directives "
                                        "not permitted", p);
                      else if (dir == NULL
-                         || dir->id == PRAGMA_OMP_END
-                         || (!dir->second && directive[1])
-                         || (!dir->third && directive[2]))
+                              || 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
index 9e282c7b9f127490d17f67eecba5cf7413508a53..6c6ffdaf343bca42d3807a6ab02366ed7dd6de62 100644 (file)
@@ -59,6 +59,7 @@ struct gfc_omp_directive {
    and "nothing".  */
 
 static const struct gfc_omp_directive gfc_omp_directives[] = {
+  /* allocate as alias for allocators is also executive. */
   {"allocate", GFC_OMP_DIR_DECLARATIVE, ST_OMP_ALLOCATE},
   {"allocators", GFC_OMP_DIR_EXECUTABLE, ST_OMP_ALLOCATORS},
   {"assumes", GFC_OMP_DIR_INFORMATIONAL, ST_OMP_ASSUMES},
@@ -68,6 +69,7 @@ static const struct gfc_omp_directive gfc_omp_directives[] = {
   {"cancellation point", GFC_OMP_DIR_EXECUTABLE, ST_OMP_CANCELLATION_POINT},
   {"cancel", GFC_OMP_DIR_EXECUTABLE, ST_OMP_CANCEL},
   {"critical", GFC_OMP_DIR_EXECUTABLE, ST_OMP_CRITICAL},
+  /* {"declare induction", GFC_OMP_DIR_DECLARATIVE, ST_OMP_DECLARE_INDUCTION}, */
   /* {"declare mapper", GFC_OMP_DIR_DECLARATIVE, ST_OMP_DECLARE_MAPPER}, */
   {"declare reduction", GFC_OMP_DIR_DECLARATIVE, ST_OMP_DECLARE_REDUCTION},
   {"declare simd", GFC_OMP_DIR_DECLARATIVE, ST_OMP_DECLARE_SIMD},
@@ -79,7 +81,10 @@ static const struct gfc_omp_directive gfc_omp_directives[] = {
   {"do", GFC_OMP_DIR_EXECUTABLE, ST_OMP_DO},
   /* "error" becomes GFC_OMP_DIR_EXECUTABLE with at(execution) */
   {"error", GFC_OMP_DIR_UTILITY, ST_OMP_ERROR},
+  /* {"flatten", GFC_OMP_DIR_EXECUTABLE, ST_OMP_FLATTEN}, */
   {"flush", GFC_OMP_DIR_EXECUTABLE, ST_OMP_FLUSH},
+  /* {"fuse", GFC_OMP_DIR_EXECUTABLE, ST_OMP_FLUSE}, */
+  /* {"interchange", GFC_OMP_DIR_EXECUTABLE, ST_OMP_INTERCHANGE}, */
   {"interop", GFC_OMP_DIR_EXECUTABLE, ST_OMP_INTEROP},
   {"loop", GFC_OMP_DIR_EXECUTABLE, ST_OMP_LOOP},
   {"masked", GFC_OMP_DIR_EXECUTABLE, ST_OMP_MASKED},
@@ -98,11 +103,15 @@ static const struct gfc_omp_directive gfc_omp_directives[] = {
   {"section", GFC_OMP_DIR_SUBSIDIARY, ST_OMP_SECTION},
   {"simd", GFC_OMP_DIR_EXECUTABLE, ST_OMP_SIMD},
   {"single", GFC_OMP_DIR_EXECUTABLE, ST_OMP_SINGLE},
+  /* {"split", GFC_OMP_DIR_EXECUTABLE, ST_OMP_SPLIT}, */
+  /* {"strip", GFC_OMP_DIR_EXECUTABLE, ST_OMP_STRIP}, */
   {"target data", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TARGET_DATA},
   {"target enter data", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TARGET_ENTER_DATA},
   {"target exit data", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TARGET_EXIT_DATA},
   {"target update", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TARGET_UPDATE},
   {"target", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TARGET},
+  /* {"taskgraph", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TASKGRAPH}, */
+  /* {"task iteration", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TASK_ITERATION}, */
   {"taskloop", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TASKLOOP},
   {"taskwait", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TASKWAIT},
   {"taskyield", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TASKYIELD},
@@ -111,6 +120,7 @@ static const struct gfc_omp_directive gfc_omp_directives[] = {
   {"threadprivate", GFC_OMP_DIR_DECLARATIVE, ST_OMP_THREADPRIVATE},
   {"tile", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TILE},
   {"unroll", GFC_OMP_DIR_EXECUTABLE, ST_OMP_UNROLL},
+  /* {"workdistribute", GFC_OMP_DIR_EXECUTABLE, ST_OMP_WORKDISTRIBUTE}, */
   {"workshare", GFC_OMP_DIR_EXECUTABLE, ST_OMP_WORKSHARE},
 };
 
index 95a65fd06ceec8be4904123785c0cae851f867c6..2cc066f4604f5f57737c49c8437d18a9452106d4 100644 (file)
@@ -31,12 +31,14 @@ foo (int i, int *a)
   ;
   #pragma omp assume contains (begin assumes)                  /* { dg-error "invalid OpenMP directive name in 'contains' clause argument" } */
   ;
-  #pragma omp assume contains (end assumes)                    /* { dg-error "invalid OpenMP directive name in 'contains' clause argument" } */
+  #pragma omp assume contains (end assumes)                    /* { dg-error "unknown OpenMP directive name in 'contains' clause argument" } */
   ;
   #pragma omp assume contains (foo)                            /* { dg-error "unknown OpenMP directive name in 'contains' clause argument" } */
   ;
   #pragma omp assume absent (target enter something)           /* { dg-error "unknown OpenMP directive name in 'absent' clause argument" } */
   ;
+  #pragma omp assume contains (declare mapper)                 /* { dg-error "invalid OpenMP directive name in 'contains' clause argument: declarative, informational, and meta directives not permitted" } */
+  ;
   #pragma omp assume foobar                                    /* { dg-error "expected assumption clause" } */
   ;
   #pragma omp assume ext_GCC_foobarbaz, ext_GCC_baz (1, 12, 1 < 17), no_parallelism    /* { dg-warning "unknown assumption clause 'ext_GCC_foobarbaz'" } */
index 68b88bed9e43a0e565f78913b125ac4fa60a6a8d..ee03b09df1d67f7e9f1ca7b69b09990ccfc1b056 100644 (file)
@@ -13,7 +13,7 @@
 #pragma omp assumes absent (assume)                            /* { dg-error "invalid OpenMP directive name in 'absent' clause argument" } */
 #pragma omp assumes absent (assumes)                           /* { dg-error "invalid OpenMP directive name in 'absent' clause argument" } */
 #pragma omp assumes contains (begin assumes)                   /* { dg-error "invalid OpenMP directive name in 'contains' clause argument" } */
-#pragma omp assumes contains (end assumes)                     /* { dg-error "invalid OpenMP directive name in 'contains' clause argument" } */
+#pragma omp assumes contains (end assumes)                     /* { dg-error "unknown OpenMP directive name in 'contains' clause argument" } */
 #pragma omp assumes contains (foo)                             /* { dg-error "unknown OpenMP directive name in 'contains' clause argument" } */
 #pragma omp assumes absent (target enter something)            /* { dg-error "unknown OpenMP directive name in 'absent' clause argument" } */
 #pragma omp assumes foobar                                     /* { dg-error "expected assumption clause" } */
index 66b918078083d965e06ba5723dc83b6502a16eac..189026d023721473ad3131ba7dc8cf2858357ef9 100644 (file)
@@ -43,7 +43,7 @@ void f14 (void) {}
 #pragma omp begin assumes contains (begin assumes)                     /* { dg-error "invalid OpenMP directive name in 'contains' clause argument" } */
 void f15 (void) {}
 #pragma omp end assumes
-#pragma omp begin assumes contains (end assumes)                       /* { dg-error "invalid OpenMP directive name in 'contains' clause argument" } */
+#pragma omp begin assumes contains (end assumes)                       /* { dg-error "unknown OpenMP directive name in 'contains' clause argument" } */
 void f16 (void) {}
 #pragma omp end assumes
 #pragma omp begin assumes contains (foo)                               /* { dg-error "unknown OpenMP directive name in 'contains' clause argument" } */