Skip to content

Commit 46944d1

Browse files
authored
[flang][OpenMP] Extract OMP version hint into helper functions, NFC (llvm#113621)
1 parent 06664fd commit 46944d1

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ namespace Fortran::semantics {
3838
CheckAllowedClause(llvm::omp::Y); \
3939
}
4040

41+
std::string ThisVersion(unsigned version) {
42+
std::string tv{
43+
std::to_string(version / 10) + "." + std::to_string(version % 10)};
44+
return "OpenMP v" + tv;
45+
}
46+
47+
std::string TryVersion(unsigned version) {
48+
return "try -fopenmp-version=" + std::to_string(version);
49+
}
50+
4151
// 'OmpWorkshareBlockChecker' is used to check the validity of the assignment
4252
// statements and the expressions enclosed in an OpenMP Workshare construct
4353
class OmpWorkshareBlockChecker {
@@ -200,14 +210,10 @@ bool OmpStructureChecker::CheckAllowedClause(llvmOmpClause clause) {
200210
auto clauseName{parser::ToUpperCaseLetters(getClauseName(clause).str())};
201211
auto dirName{parser::ToUpperCaseLetters(getDirectiveName(dir).str())};
202212

203-
std::string thisVersion{
204-
std::to_string(version / 10) + "." + std::to_string(version % 10)};
205-
std::string goodVersion{std::to_string(allowedInVersion)};
206-
207213
context_.Say(dirCtx.clauseSource,
208-
"%s clause is not allowed on directive %s in OpenMP v%s, "
209-
"try -fopenmp-version=%d"_err_en_US,
210-
clauseName, dirName, thisVersion, allowedInVersion);
214+
"%s clause is not allowed on directive %s in %s, %s"_err_en_US,
215+
clauseName, dirName, ThisVersion(version),
216+
TryVersion(allowedInVersion));
211217
}
212218
}
213219
return CheckAllowed(clause);
@@ -3378,8 +3384,8 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Lastprivate &x) {
33783384
std::to_string(version / 10) + "." + std::to_string(version % 10)};
33793385
context_.Say(GetContext().clauseSource,
33803386
"LASTPRIVATE clause with CONDITIONAL modifier is not "
3381-
"allowed in OpenMP v%s, try -fopenmp-version=%d"_err_en_US,
3382-
thisVersion, allowedInVersion);
3387+
"allowed in %s, %s"_err_en_US,
3388+
ThisVersion(version), TryVersion(allowedInVersion));
33833389
}
33843390
}
33853391
}

0 commit comments

Comments
 (0)