Skip to content

Commit ae75884

Browse files
kparzyszmjklemm
andauthored
[Frontend][OpenMP] Add 6.1 as a valid OpenMP version (#153628)
Co-authored-by: Michael Klemm <[email protected]>
1 parent 2497864 commit ae75884

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

flang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,7 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
11871187
llvm::Triple t(res.getTargetOpts().triple);
11881188

11891189
constexpr unsigned newestFullySupported = 31;
1190+
constexpr unsigned latestFinalized = 60;
11901191
// By default OpenMP is set to the most recent fully supported version
11911192
res.getLangOpts().OpenMPVersion = newestFullySupported;
11921193
res.getFrontendOpts().features.Enable(
@@ -1209,12 +1210,26 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
12091210
diags.Report(diagID) << value << arg->getAsString(args) << versions.str();
12101211
};
12111212

1213+
auto reportFutureVersion = [&](llvm::StringRef value) {
1214+
const unsigned diagID = diags.getCustomDiagID(
1215+
clang::DiagnosticsEngine::Warning,
1216+
"The specification for OpenMP version %0 is still under development; "
1217+
"the syntax and semantics of new features may be subject to change");
1218+
std::string buffer;
1219+
llvm::raw_string_ostream versions(buffer);
1220+
llvm::interleaveComma(ompVersions, versions);
1221+
1222+
diags.Report(diagID) << value;
1223+
};
1224+
12121225
llvm::StringRef value = arg->getValue();
12131226
if (!value.getAsInteger(/*radix=*/10, version)) {
12141227
if (llvm::is_contained(ompVersions, version)) {
12151228
res.getLangOpts().OpenMPVersion = version;
12161229

1217-
if (version > newestFullySupported)
1230+
if (version > latestFinalized)
1231+
reportFutureVersion(value);
1232+
else if (version > newestFullySupported)
12181233
diags.Report(clang::diag::warn_openmp_incomplete) << version;
12191234
} else if (llvm::is_contained(oldVersions, version)) {
12201235
const unsigned diagID =

flang/test/Driver/fopenmp-version.F90

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@
2222

2323
!RUN: not %flang -c -fopenmp -fopenmp-version=29 %s 2>&1 | FileCheck --check-prefix=ERR-BAD %s
2424

25-
!ERR-BAD: error: '29' is not a valid OpenMP version in '-fopenmp-version=29', valid versions are 31, 40, 45, 50, 51, 52, 60
25+
!ERR-BAD: error: '29' is not a valid OpenMP version in '-fopenmp-version=29', valid versions are 31, 40, 45, 50, 51, 52, 60, 61
26+
27+
!RUN: %flang -c -fopenmp -fopenmp-version=61 %s 2>&1 | FileCheck --check-prefix=FUTURE %s
28+
29+
!FUTURE: The specification for OpenMP version 61 is still under development; the syntax and semantics of new features may be subject to change

llvm/lib/Frontend/OpenMP/OMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ bool isCombinedConstruct(Directive D) {
190190
}
191191

192192
ArrayRef<unsigned> getOpenMPVersions() {
193-
static unsigned Versions[]{31, 40, 45, 50, 51, 52, 60};
193+
static unsigned Versions[]{31, 40, 45, 50, 51, 52, 60, 61};
194194
return Versions;
195195
}
196196

0 commit comments

Comments
 (0)