[flang-commits] [flang] [llvm] [flang][OpenMP] Switch clause verification to descriptor-based (PR #229527)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Tue Oct 20 10:52:47 PDT 2026
================
@@ -326,6 +352,251 @@ static ResultTy VerifyUltimate(
return result;
}
+bool OmpStructureChecker::VerifyClauseVersion(
+ parser::OmpDirectiveName dirName, const AppliedClauseInfo &info) {
+ llvm::omp::Version version{context_.langOptions().getOpenMPVersion()};
+ llvm::omp::Version maxVer{std::numeric_limits<int>::max()};
+ bool isCancel{dirName.v == llvm::omp::Directive::OMPD_cancel ||
+ dirName.v == llvm::omp::Directive::OMPD_cancellation_point};
+
+ auto result = VerifyVersions(info, dirName.v, version);
+
+ for (auto &[c, svr] : result) {
+ std::string cname{GetUpperName(c, version)};
+ std::string dname{GetUpperName(dirName.v, version)};
+ llvm::omp::Version since(svr.second.Min);
+ llvm::omp::Version until(svr.second.Max);
+
+ // Cancellation construct type clauses are directive names. They are
+ // only allowed on CANCEL and CANCELLATION_POINT directives. They may
+ // appear as byproducts of parsing an invalid directive name,
+ // e.g. SECTIONS PARALLEL, where SECTIONS will be the directive name,
+ // and PARALLEL will be a cancellation-construct-type clause.
+ // This may cause confusing error messages to be emitted, so deal with
+ // these cases separately.
+ if (!isCancel && c == llvm::omp::Clause::OMPC_cancellation_construct_type) {
+ context_.Say(svr.first, "%s cannot follow %s"_err_en_US,
+ parser::ToUpperCaseLetters(svr.first.ToString()), dname);
+ continue;
+ }
+
+ if (since == maxVer && until == 0u) {
+ context_.Say(svr.first,
+ "%s clause is not allowed on %s directive"_err_en_US, cname, dname);
+ } else if (since != maxVer && version < since) {
+ context_.Warn(common::UsageWarning::OpenMPFuture, svr.first,
+ "%s clause is not allowed on %s directive in %s, %s"_warn_en_US,
----------------
kparzysz wrote:
Fixed.
https://github.com/llvm/llvm-project/pull/229527
More information about the flang-commits
mailing list