[flang-commits] [flang] [flang][OpenMP] Support omx/ompx extension sentinels (PR #218475)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Wed Aug 26 11:51:46 PDT 2026
================
@@ -49,7 +49,23 @@ using namespace Fortran::parser::omp;
state.GetLocation(), std::min<size_t>(64, state.BytesRemaining()));
}
-constexpr auto startOmpLine = skipStuffBeforeStatement >> "!$OMP "_sptok;
+// Accept the standard "!$omp" sentinel as well as the implementation-defined
+// extension sentinels "!$omx" (fixed form) and "!$ompx" (free form) defined in
+// OpenMP 5.2, section 3.1. The prescanner normalizes the comment character of
+// fixed-form sentinels (c$omx, *$omx) to '!'.
+//
+// The extension sentinels are tried before "!$omp". Because "omp" is a prefix
+// of "ompx", matching "!$omp" first would consume the start of an "!$ompx" line
+// and leave a stray "x" ahead of the directive name; trying "!$ompx"/"!$omx"
+// first avoids that. "_sptok" (rather than "_id") is required because in fixed
+// form the prescanner can emit the sentinel immediately followed by the
+// directive name with no intervening space (e.g. "c$omp0parallel" becomes
+// "!$ompparallel"); "_id" would reject such a token because it is followed by
+// an identifier character.
+constexpr auto ompxSentinel = "!$OMPX "_sptok || "!$OMX "_sptok;
+constexpr auto ompSentinel = "!$OMP "_sptok;
----------------
kparzysz wrote:
The spaces inside tokens will be ignored.
https://github.com/llvm/llvm-project/pull/218475
More information about the flang-commits
mailing list