[flang-commits] [flang] 46944d1 - [flang][OpenMP] Extract OMP version hint into helper functions, NFC (#113621)
via flang-commits
flang-commits at lists.llvm.org
Tue Oct 29 04:43:43 PDT 2024
Author: Krzysztof Parzyszek
Date: 2024-10-29T06:43:40-05:00
New Revision: 46944d1f950d042695197038ab3f1bf25ace261b
URL: https://github.com/llvm/llvm-project/commit/46944d1f950d042695197038ab3f1bf25ace261b
DIFF: https://github.com/llvm/llvm-project/commit/46944d1f950d042695197038ab3f1bf25ace261b.diff
LOG: [flang][OpenMP] Extract OMP version hint into helper functions, NFC (#113621)
Added:
Modified:
flang/lib/Semantics/check-omp-structure.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 599cc61a83bf0a..0c3a0e76df6a6a 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -38,6 +38,16 @@ namespace Fortran::semantics {
CheckAllowedClause(llvm::omp::Y); \
}
+std::string ThisVersion(unsigned version) {
+ std::string tv{
+ std::to_string(version / 10) + "." + std::to_string(version % 10)};
+ return "OpenMP v" + tv;
+}
+
+std::string TryVersion(unsigned version) {
+ return "try -fopenmp-version=" + std::to_string(version);
+}
+
// 'OmpWorkshareBlockChecker' is used to check the validity of the assignment
// statements and the expressions enclosed in an OpenMP Workshare construct
class OmpWorkshareBlockChecker {
@@ -200,14 +210,10 @@ bool OmpStructureChecker::CheckAllowedClause(llvmOmpClause clause) {
auto clauseName{parser::ToUpperCaseLetters(getClauseName(clause).str())};
auto dirName{parser::ToUpperCaseLetters(getDirectiveName(dir).str())};
- std::string thisVersion{
- std::to_string(version / 10) + "." + std::to_string(version % 10)};
- std::string goodVersion{std::to_string(allowedInVersion)};
-
context_.Say(dirCtx.clauseSource,
- "%s clause is not allowed on directive %s in OpenMP v%s, "
- "try -fopenmp-version=%d"_err_en_US,
- clauseName, dirName, thisVersion, allowedInVersion);
+ "%s clause is not allowed on directive %s in %s, %s"_err_en_US,
+ clauseName, dirName, ThisVersion(version),
+ TryVersion(allowedInVersion));
}
}
return CheckAllowed(clause);
@@ -3378,8 +3384,8 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Lastprivate &x) {
std::to_string(version / 10) + "." + std::to_string(version % 10)};
context_.Say(GetContext().clauseSource,
"LASTPRIVATE clause with CONDITIONAL modifier is not "
- "allowed in OpenMP v%s, try -fopenmp-version=%d"_err_en_US,
- thisVersion, allowedInVersion);
+ "allowed in %s, %s"_err_en_US,
+ ThisVersion(version), TryVersion(allowedInVersion));
}
}
}
More information about the flang-commits
mailing list