diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 265ba8e031a6..4719a242035e 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1187,6 +1187,7 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args, llvm::Triple t(res.getTargetOpts().triple); constexpr unsigned newestFullySupported = 31; + constexpr unsigned latestFinalized = 60; // By default OpenMP is set to the most recent fully supported version res.getLangOpts().OpenMPVersion = newestFullySupported; res.getFrontendOpts().features.Enable( @@ -1209,12 +1210,26 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args, diags.Report(diagID) << value << arg->getAsString(args) << versions.str(); }; + auto reportFutureVersion = [&](llvm::StringRef value) { + const unsigned diagID = diags.getCustomDiagID( + clang::DiagnosticsEngine::Warning, + "The specification for OpenMP version %0 is still under development; " + "the syntax and semantics of new features may be subject to change"); + std::string buffer; + llvm::raw_string_ostream versions(buffer); + llvm::interleaveComma(ompVersions, versions); + + diags.Report(diagID) << value; + }; + llvm::StringRef value = arg->getValue(); if (!value.getAsInteger(/*radix=*/10, version)) { if (llvm::is_contained(ompVersions, version)) { res.getLangOpts().OpenMPVersion = version; - if (version > newestFullySupported) + if (version > latestFinalized) + reportFutureVersion(value); + else if (version > newestFullySupported) diags.Report(clang::diag::warn_openmp_incomplete) << version; } else if (llvm::is_contained(oldVersions, version)) { const unsigned diagID = diff --git a/flang/test/Driver/fopenmp-version.F90 b/flang/test/Driver/fopenmp-version.F90 index c2866561461b..59406d3dd32c 100644 --- a/flang/test/Driver/fopenmp-version.F90 +++ b/flang/test/Driver/fopenmp-version.F90 @@ -22,4 +22,8 @@ !RUN: not %flang -c -fopenmp -fopenmp-version=29 %s 2>&1 | FileCheck --check-prefix=ERR-BAD %s -!ERR-BAD: error: '29' is not a valid OpenMP version in '-fopenmp-version=29', valid versions are 31, 40, 45, 50, 51, 52, 60 +!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 + +!RUN: %flang -c -fopenmp -fopenmp-version=61 %s 2>&1 | FileCheck --check-prefix=FUTURE %s + +!FUTURE: The specification for OpenMP version 61 is still under development; the syntax and semantics of new features may be subject to change diff --git a/llvm/lib/Frontend/OpenMP/OMP.cpp b/llvm/lib/Frontend/OpenMP/OMP.cpp index 555e2a61e411..9e625b809de9 100644 --- a/llvm/lib/Frontend/OpenMP/OMP.cpp +++ b/llvm/lib/Frontend/OpenMP/OMP.cpp @@ -190,7 +190,7 @@ bool isCombinedConstruct(Directive D) { } ArrayRef getOpenMPVersions() { - static unsigned Versions[]{31, 40, 45, 50, 51, 52, 60}; + static unsigned Versions[]{31, 40, 45, 50, 51, 52, 60, 61}; return Versions; }