[Flang] Fix -Wopen-mp-* and -Wopen-acc-* flag spellings (#188434)

The CamelCase-to-hyphenated conversion was incorrectly splitting
"OpenMP" and "OpenACC" into "open-mp" and "open-acc", producing wrong -W
flag names like -Wopen-mp-usage instead of -Wopenmp-usage. Fix the
conversion to treat these as compound names, keep the old spellings as
deprecated aliases, and emit a warning when deprecated spellings are
used.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michael Klemm
2026-04-28 17:26:29 +02:00
committed by GitHub
parent eecec864d1
commit 40ad10a8ae
24 changed files with 200 additions and 79 deletions

View File

@@ -35,6 +35,9 @@ page](https://llvm.org/releases/).
## New Compiler Flags
- The warning flags with prefixes -Wopen-mp and -Wopen-acc have been deprecated in favor of corrected spellings with the respective prefixes -Wopenmp and -Wopenacc. Removal of the deprecated options is planned for LLVM 25 (July 2027).
## Windows Support
## Fortran Language Changes in Flang

View File

@@ -149,6 +149,19 @@ public:
void AddAlternativeCliSpelling(UsageWarning w, std::string input) {
cliOptions_.insert({input, {w}});
}
void AddDeprecatedCliSpelling(LanguageFeature f,
const std::string &deprecated, const std::string &canonical) {
cliOptions_.insert({deprecated, {f}});
deprecatedCliOptions_.insert({deprecated, canonical});
}
void AddDeprecatedCliSpelling(UsageWarning w, const std::string &deprecated,
const std::string &canonical) {
cliOptions_.insert({deprecated, {w}});
deprecatedCliOptions_.insert({deprecated, canonical});
}
// Returns the canonical spelling if the input is a deprecated spelling.
std::optional<std::string_view> CheckDeprecatedSpelling(
std::string_view input) const;
void ReplaceCliCanonicalSpelling(LanguageFeature f, std::string input);
void ReplaceCliCanonicalSpelling(UsageWarning w, std::string input);
std::string_view getDefaultCliSpelling(LanguageFeature f) const {
@@ -165,6 +178,8 @@ private:
// Map from Cli syntax of language features and usage warnings to their enum
// values.
std::unordered_map<std::string, LanguageFeatureOrWarning> cliOptions_;
// Map from deprecated Cli spellings to their canonical replacements.
std::unordered_map<std::string, std::string> deprecatedCliOptions_;
// These two arrays map the enum values to their cannonical Cli spellings.
// Since each of the CanonicalSpelling is a string in the domain of the map
// above we just use a view of the string instead of another copy.

View File

@@ -1048,14 +1048,27 @@ static bool parseDiagArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
// this has to change when other -W<opt>'s are supported.
if (args.hasArg(clang::options::OPT_W_Joined)) {
const auto &wArgs = args.getAllArgValues(clang::options::OPT_W_Joined);
for (const auto &wArg : wArgs) {
// TODO: Consider using std::string_view instead of llvm::StringRef
// when moving to C++20:
for (const llvm::StringRef wArg : wArgs) {
if (wArg == "error") {
res.setWarnAsErr(true);
// -Wfatal-errors
} else if (wArg == "fatal-errors") {
res.setMaxErrors(1);
// -W[no-]<feature>
} else if (!features.EnableWarning(wArg)) {
} else if (features.EnableWarning(wArg)) {
if (auto canonical{features.CheckDeprecatedSpelling(wArg)}) {
std::string suggestion{*canonical};
if (wArg.starts_with("no-")) {
suggestion = "no-" + suggestion;
}
const unsigned diagID =
diags.getCustomDiagID(clang::DiagnosticsEngine::Warning,
"-W%0 is deprecated; use -W%1 instead");
diags.Report(diagID) << wArg << suggestion;
}
} else {
const unsigned diagID = diags.getCustomDiagID(
clang::DiagnosticsEngine::Error, "Unknown diagnostic option: -W%0");
diags.Report(diagID) << wArg;

View File

@@ -10,6 +10,7 @@
#include "flang/Common/idioms.h"
#include "flang/Parser/characters.h"
#include "flang/Support/Fortran.h"
#include "llvm/ADT/StringRef.h"
#include <string>
#include <string_view>
@@ -35,6 +36,26 @@ static std::vector<std::string_view> SplitCamelCase(std::string_view x) {
return result;
}
// Compound names whose hyphenated CamelCase splitting is wrong.
// Each entry maps the incorrect (deprecated) hyphenated form produced by
// SplitCamelCase to the correct (canonical) form.
static constexpr std::pair<std::string_view, std::string_view>
compoundNameFixups[]{{"open-mp", "openmp"}, {"open-acc", "openacc"}};
// Replace all occurrences of 'from' with 'to' in 's', but only when the
// match is at a word boundary (end of string or followed by '-') to avoid
// e.g. "open-access" -> "openaccess".
static void ReplaceAtWordBoundary(
std::string &s, std::string_view from, std::string_view to) {
for (size_t pos = s.find(from); pos != std::string::npos;
pos = s.find(from, pos + to.size())) {
size_t end = pos + from.size();
if (end == s.size() || s[end] == '-') {
s.replace(pos, from.size(), to);
}
}
}
// Namespace for helper functions for parsing Cli options used instead of static
// so that there can be unit tests for this function.
namespace details {
@@ -47,6 +68,10 @@ std::string CamelCaseToLowerCaseHyphenated(std::string_view x) {
result += i == 0 ? "" : "-";
result += word;
}
// Fix known compound names that should not be hyphen-separated.
for (auto [deprecated, canonical] : compoundNameFixups) {
ReplaceAtWordBoundary(result, deprecated, canonical);
}
return result;
}
} // namespace details
@@ -70,12 +95,37 @@ LanguageFeatureControl::LanguageFeatureControl() {
std::move(cliOption);
});
// Fix CLI spellings where the auto-generated hyphenation is wrong.
// TODO: -Wopen-mp-* should be fixed in a central place. See
// see Discourse at
// https://discourse.llvm.org/t/openmp-misspelling-of-wopen-mp/90196.
ReplaceCliCanonicalSpelling(LanguageFeature::OpenMPThreadprivateEquivalence,
"openmp-threadprivate-equivalence");
// Register deprecated "open-mp-*" and "open-acc-*" spellings as aliases.
// The canonical spellings are now "openmp-*" and "openacc-*".
auto makeDeprecatedSpelling = [](std::string_view canonical) {
std::string deprecated{canonical};
bool replaced{false};
for (auto [deprecatedForm, canonicalForm] : compoundNameFixups) {
// Reverse direction: canonical -> deprecated.
for (auto pos{deprecated.find(canonicalForm)}; pos != std::string::npos;
pos = deprecated.find(canonicalForm, pos + deprecatedForm.size())) {
deprecated.replace(pos, canonicalForm.size(), deprecatedForm);
replaced = true;
}
}
return std::pair{deprecated, replaced};
};
ForEachLanguageFeature([&](auto feature) {
std::string_view canonical{
languageFeatureCliCanonicalSpelling_[EnumToInt(feature)]};
auto [deprecated, replaced]{makeDeprecatedSpelling(canonical)};
if (replaced) {
AddDeprecatedCliSpelling(feature, deprecated, std::string{canonical});
}
});
ForEachUsageWarning([&](auto warning) {
std::string_view canonical{
usageWarningCliCanonicalSpelling_[EnumToInt(warning)]};
auto [deprecated, replaced]{makeDeprecatedSpelling(canonical)};
if (replaced) {
AddDeprecatedCliSpelling(warning, deprecated, std::string{canonical});
}
});
// These features must be explicitly enabled by command line options.
disable_.set(LanguageFeature::OldDebugLines);
@@ -169,6 +219,7 @@ LanguageFeatureControl::LanguageFeatureControl() {
std::optional<LanguageControlFlag> LanguageFeatureControl::FindWarning(
std::string_view input) {
bool negated{false};
// TODO: replace with starts_with when moving to C++20
if (input.size() > 3 && input.substr(0, 3) == "no-") {
negated = true;
input = input.substr(3);
@@ -179,6 +230,21 @@ std::optional<LanguageControlFlag> LanguageFeatureControl::FindWarning(
return std::nullopt;
}
std::optional<std::string_view> LanguageFeatureControl::CheckDeprecatedSpelling(
std::string_view input) const {
// Strip "no-" prefix for lookup, same as FindWarning does.
// TODO: Consider using std::string_view instead of llvm::StringRef
// when moving to C++20:
if (llvm::StringRef{input}.starts_with("no-")) {
input = input.substr(3);
}
if (auto it{deprecatedCliOptions_.find(std::string{input})};
it != deprecatedCliOptions_.end()) {
return it->second;
}
return std::nullopt;
}
bool LanguageFeatureControl::EnableWarning(std::string_view input) {
if (auto warningAndEnabled{FindWarning(input)}) {
EnableWarning(warningAndEnabled->first, warningAndEnabled->second);

View File

@@ -0,0 +1,23 @@
! Test that the deprecated -Wopen-mp-* and -Wopen-acc-* spellings produce
! deprecation warnings and suggest the canonical -Wopenmp-* / -Wopenacc-*
! spellings.
! RUN: %flang_fc1 -fsyntax-only -Wopen-mp-usage %s 2>&1 | FileCheck --check-prefix=DEPRECATED %s
! RUN: %flang_fc1 -fsyntax-only -Wno-open-mp-usage %s 2>&1 | FileCheck --check-prefix=DEPRECATED-NO %s
! RUN: %flang_fc1 -fsyntax-only -Wopen-acc-usage %s 2>&1 | FileCheck --check-prefix=DEPRECATED-ACC %s
! RUN: %flang_fc1 -fsyntax-only -Wopenmp-usage %s 2>&1 | FileCheck --allow-empty --check-prefix=CANONICAL %s
! RUN: %flang_fc1 -fsyntax-only -Wopenacc-usage %s 2>&1 | FileCheck --allow-empty --check-prefix=CANONICAL %s
! RUN: %flang -fsyntax-only -Wopen-mp-usage %s 2>&1 | FileCheck --check-prefix=DEPRECATED %s
! RUN: %flang -fsyntax-only -Wno-open-mp-usage %s 2>&1 | FileCheck --check-prefix=DEPRECATED-NO %s
! RUN: %flang -fsyntax-only -Wopen-acc-usage %s 2>&1 | FileCheck --check-prefix=DEPRECATED-ACC %s
! RUN: %flang -fsyntax-only -Wopenmp-usage %s 2>&1 | FileCheck --allow-empty --check-prefix=CANONICAL %s
! RUN: %flang -fsyntax-only -Wopenacc-usage %s 2>&1 | FileCheck --allow-empty --check-prefix=CANONICAL %s
! DEPRECATED: warning: -Wopen-mp-usage is deprecated; use -Wopenmp-usage instead
! DEPRECATED-NO: warning: -Wno-open-mp-usage is deprecated; use -Wno-openmp-usage instead
! DEPRECATED-ACC: warning: -Wopen-acc-usage is deprecated; use -Wopenacc-usage instead
! CANONICAL-NOT: deprecated
program test
end program test

View File

@@ -14,7 +14,7 @@ module openacc_declare_validity
!$acc declare create(aa, bb)
!WARNING: 'aa' in the CREATE clause is already present in the same clause in this module [-Wopen-acc-usage]
!WARNING: 'aa' in the CREATE clause is already present in the same clause in this module [-Wopenacc-usage]
!$acc declare create(aa)
!$acc declare link(ab)

View File

@@ -11,7 +11,7 @@ program allocate_align_tree
integer :: z, t, xx
t = 2
z = 3
!WARNING: The executable form of the OpenMP ALLOCATE directive has been deprecated, please use ALLOCATORS instead [-Wopen-mp-usage]
!WARNING: The executable form of the OpenMP ALLOCATE directive has been deprecated, please use ALLOCATORS instead [-Wopenmp-usage]
!ERROR: Must be a constant value
!$omp allocate(j) align(xx)
!ERROR: The alignment should be positive

View File

@@ -19,7 +19,7 @@ use omp_lib
!$omp allocate(y)
print *, a
!WARNING: The executable form of the OpenMP ALLOCATE directive has been deprecated, please use ALLOCATORS instead [-Wopen-mp-usage]
!WARNING: The executable form of the OpenMP ALLOCATE directive has been deprecated, please use ALLOCATORS instead [-Wopenmp-usage]
!$omp allocate(x) allocator(omp_default_mem_alloc)
allocate ( x(a), darray(a, b) )
end subroutine sema

View File

@@ -483,14 +483,14 @@ use omp_lib
! 2.13.1 master
!$omp parallel
!WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead [-Wopen-mp-usage]
!WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead [-Wopenmp-usage]
!$omp master
a=3.14
!$omp end master
!$omp end parallel
!$omp parallel
!WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead [-Wopen-mp-usage]
!WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead [-Wopenmp-usage]
!ERROR: NUM_THREADS clause is not allowed on the MASTER directive
!$omp master num_threads(4)
a=3.14

View File

@@ -56,10 +56,10 @@ module m2
contains
subroutine foo
!$omp declare target
!WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive [-Wopen-mp-usage]
!WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive [-Wopen-mp-usage]
!WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive [-Wopenmp-usage]
!WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive [-Wopenmp-usage]
!$omp declare target (foo, N, M)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
@@ -68,7 +68,7 @@ contains
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
!$omp declare target enter(Q, S) link(R)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
!ERROR: MAP clause is not allowed on the DECLARE TARGET directive
!$omp declare target to(Q) map(from:Q)

View File

@@ -51,84 +51,84 @@ module declare_target01
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
!$omp declare target (y%KIND)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (my_var)
!$omp declare target enter (my_var)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (my_var) device_type(host)
!$omp declare target enter (my_var) device_type(host)
!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (my_var%t_i)
!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
!$omp declare target enter (my_var%t_i)
!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (my_var%t_arr)
!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
!$omp declare target enter (my_var%t_arr)
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (my_var%kind_param)
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
!$omp declare target enter (my_var%kind_param)
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (my_var%len_param)
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
!$omp declare target enter (my_var%len_param)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (arr)
!$omp declare target enter (arr)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (arr) device_type(nohost)
!$omp declare target enter (arr) device_type(nohost)
!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (arr(1))
!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
!$omp declare target enter (arr(1))
!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (arr(1:2))
!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
!$omp declare target enter (arr(1:2))
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (x%KIND)
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
!$omp declare target enter (x%KIND)
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (w%LEN)
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
!$omp declare target enter (w%LEN)
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (y%KIND)
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive

View File

@@ -16,17 +16,17 @@ program declare_target02
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
!$omp declare target (a1)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (arr1_to)
!$omp declare target enter (arr1_to)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (blk1_to)
!$omp declare target enter (blk1_to)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
!$omp declare target to (a1_to)
@@ -44,7 +44,7 @@ program declare_target02
!ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
!$omp declare target (eq_a)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
!$omp declare target to (eq_a)
@@ -57,7 +57,7 @@ program declare_target02
!ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
!$omp declare target (eq_c)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
!$omp declare target to (eq_c)
@@ -87,26 +87,26 @@ contains
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
!$omp declare target (a3)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
!$omp declare target to (arr2_to)
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
!$omp declare target enter (arr2_to)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (arr3_to)
!$omp declare target enter (arr3_to)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
!$omp declare target to (a2_to)
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
!$omp declare target enter (a2_to)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
!$omp declare target to (a3_to)
@@ -137,16 +137,16 @@ module mod4
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
!$omp declare target (a4)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (arr4_to)
!$omp declare target enter (arr4_to)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (blk4_to)
!$omp declare target enter (blk4_to)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
!$omp declare target to (a4_to)
@@ -174,21 +174,21 @@ subroutine func5()
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
!$omp declare target (a5)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
!$omp declare target to (arr5_to)
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
!$omp declare target enter (arr5_to)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
!$omp declare target to (blk5_to)
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
!$omp declare target enter (blk5_to)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
!$omp declare target to (a5_to)

View File

@@ -12,7 +12,7 @@ module test_0
!ERROR: No explicit type declared for 'no_implicit_materialization_2'
!$omp declare target link(no_implicit_materialization_2)
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!ERROR: No explicit type declared for 'no_implicit_materialization_3'
!$omp declare target to(no_implicit_materialization_3)

View File

@@ -4,7 +4,7 @@
subroutine test_master()
integer :: c = 1
!WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead [-Wopen-mp-usage]
!WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead [-Wopenmp-usage]
!$omp master
c = c + 1
!$omp end master
@@ -12,7 +12,7 @@ end subroutine
subroutine test_parallel_master
integer :: c = 2
!WARNING: OpenMP directive PARALLEL MASTER has been deprecated, please use PARALLEL MASKED instead [-Wopen-mp-usage]
!WARNING: OpenMP directive PARALLEL MASTER has been deprecated, please use PARALLEL MASKED instead [-Wopenmp-usage]
!$omp parallel master
c = c + 2
!$omp end parallel master
@@ -20,7 +20,7 @@ end subroutine
subroutine test_master_taskloop_simd()
integer :: i, j = 1
!WARNING: OpenMP directive MASTER TASKLOOP SIMD has been deprecated, please use MASKED TASKLOOP SIMD instead [-Wopen-mp-usage]
!WARNING: OpenMP directive MASTER TASKLOOP SIMD has been deprecated, please use MASKED TASKLOOP SIMD instead [-Wopenmp-usage]
!$omp master taskloop simd
do i=1,10
j = j + 1
@@ -30,7 +30,7 @@ end subroutine
subroutine test_master_taskloop
integer :: i, j = 1
!WARNING: OpenMP directive MASTER TASKLOOP has been deprecated, please use MASKED TASKLOOP instead [-Wopen-mp-usage]
!WARNING: OpenMP directive MASTER TASKLOOP has been deprecated, please use MASKED TASKLOOP instead [-Wopenmp-usage]
!$omp master taskloop
do i=1,10
j = j + 1
@@ -40,7 +40,7 @@ end subroutine
subroutine test_parallel_master_taskloop_simd
integer :: i, j = 1
!WARNING: OpenMP directive PARALLEL MASTER TASKLOOP SIMD has been deprecated, please use PARALLEL MASKED TASKLOOP SIMD instead [-Wopen-mp-usage]
!WARNING: OpenMP directive PARALLEL MASTER TASKLOOP SIMD has been deprecated, please use PARALLEL MASKED TASKLOOP SIMD instead [-Wopenmp-usage]
!$omp parallel master taskloop simd
do i=1,10
j = j + 1
@@ -50,7 +50,7 @@ end subroutine
subroutine test_parallel_master_taskloop
integer :: i, j = 1
!WARNING: OpenMP directive PARALLEL MASTER TASKLOOP has been deprecated, please use PARALLEL MASKED TASKLOOP instead [-Wopen-mp-usage]
!WARNING: OpenMP directive PARALLEL MASTER TASKLOOP has been deprecated, please use PARALLEL MASKED TASKLOOP instead [-Wopenmp-usage]
!$omp parallel master taskloop
do i=1,10
j = j + 1

View File

@@ -10,7 +10,7 @@ program main
real, allocatable :: B(:)
!$omp target
!PORTABILITY: If TARGET UPDATE directive is nested inside TARGET region, the behaviour is unspecified [-Wopen-mp-usage]
!PORTABILITY: If TARGET UPDATE directive is nested inside TARGET region, the behaviour is unspecified [-Wopenmp-usage]
!$omp target update from(arrayA) to(arrayB)
do i = 1, 512
arrayA(i) = arrayB(i)
@@ -20,7 +20,7 @@ program main
!$omp parallel
!$omp target
!$omp parallel
!PORTABILITY: If TARGET UPDATE directive is nested inside TARGET region, the behaviour is unspecified [-Wopen-mp-usage]
!PORTABILITY: If TARGET UPDATE directive is nested inside TARGET region, the behaviour is unspecified [-Wopenmp-usage]
!$omp target update from(arrayA) to(arrayB)
do i = 1, 512
arrayA(i) = arrayB(i)
@@ -30,7 +30,7 @@ program main
!$omp end parallel
!$omp target
!PORTABILITY: If TARGET DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wopen-mp-usage]
!PORTABILITY: If TARGET DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wopenmp-usage]
!$omp target data map(to: a)
do i = 1, N
a = 3.14
@@ -40,12 +40,12 @@ program main
allocate(B(N))
!$omp target
!PORTABILITY: If TARGET ENTER DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wopen-mp-usage]
!PORTABILITY: If TARGET ENTER DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wopenmp-usage]
!$omp target enter data map(alloc:B)
!$omp end target
!$omp target
!PORTABILITY: If TARGET EXIT DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wopen-mp-usage]
!PORTABILITY: If TARGET EXIT DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wopenmp-usage]
!$omp target exit data map(delete:B)
!$omp end target
deallocate(B)
@@ -53,7 +53,7 @@ program main
n1 = 10
n2 = 10
!$omp target teams map(to:a)
!PORTABILITY: If TARGET DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wopen-mp-usage]
!PORTABILITY: If TARGET DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wopenmp-usage]
!ERROR: Only `DISTRIBUTE`, `PARALLEL`, or `LOOP` regions are allowed to be strictly nested inside `TEAMS` region.
!$omp target data map(n1,n2)
do i=1, n1
@@ -65,7 +65,7 @@ program main
!$omp end target teams
!$omp target teams map(to:a) map(from:n1,n2)
!PORTABILITY: If TARGET TEAMS DISTRIBUTE PARALLEL DO directive is nested inside TARGET region, the behaviour is unspecified [-Wopen-mp-usage]
!PORTABILITY: If TARGET TEAMS DISTRIBUTE PARALLEL DO directive is nested inside TARGET region, the behaviour is unspecified [-Wopenmp-usage]
!ERROR: Only `DISTRIBUTE`, `PARALLEL`, or `LOOP` regions are allowed to be strictly nested inside `TEAMS` region.
!$omp target teams distribute parallel do
do i=1, n1

View File

@@ -6,7 +6,7 @@
subroutine f
integer, save :: x
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to(x) device_type(nohost)
!$omp declare target enter(x) device_type(nohost)
end subroutine f

View File

@@ -5,7 +5,7 @@
! device constructs, such as declare target with 'to' clause and no device_type.
subroutine f
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopen-mp-usage]
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to(f)
!$omp declare target enter(f)
end subroutine f

View File

@@ -60,13 +60,13 @@ program omp_simd
!$omp end simd
!ERROR: 'd' in ALIGNED clause must be of type C_PTR, POINTER or ALLOCATABLE
!WARNING: Alignment is not a power of 2, Aligned clause will be ignored [-Wopen-mp-usage]
!WARNING: Alignment is not a power of 2, Aligned clause will be ignored [-Wopenmp-usage]
!$omp simd aligned(d:100)
do i = 1, 100
d(i) = i
end do
!WARNING: Alignment is not a power of 2, Aligned clause will be ignored [-Wopen-mp-usage]
!WARNING: Alignment is not a power of 2, Aligned clause will be ignored [-Wopenmp-usage]
!$omp simd aligned(b:65)
do i = 1, 100
b(i) = i

View File

@@ -39,7 +39,7 @@ subroutine omp_single
!$omp single private(j) copyprivate(j)
print *, "omp single", j
!ERROR: COPYPRIVATE variable 'j' may not appear on a PRIVATE or FIRSTPRIVATE clause on a SINGLE construct
!WARNING: The COPYPRIVATE clause with 'j' is already used on the SINGLE directive [-Wopen-mp-usage]
!WARNING: The COPYPRIVATE clause with 'j' is already used on the SINGLE directive [-Wopenmp-usage]
!$omp end single copyprivate(j)
!$omp single nowait

View File

@@ -52,20 +52,20 @@ program single
!ERROR: NOWAIT clause must not be used with COPYPRIVATE clause on the SINGLE directive
!$omp single copyprivate(x) nowait
print *, x
!WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wopen-mp-usage]
!WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wopenmp-usage]
!ERROR: At most one NOWAIT clause can appear on the SINGLE directive
!$omp end single copyprivate(x) nowait
!$omp single copyprivate(x)
print *, x
!WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wopen-mp-usage]
!WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wopenmp-usage]
!ERROR: NOWAIT clause must not be used with COPYPRIVATE clause on the SINGLE directive
!$omp end single copyprivate(x) nowait
!ERROR: NOWAIT clause must not be used with COPYPRIVATE clause on the SINGLE directive
!$omp single copyprivate(x, y) nowait
print *, x
!WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wopen-mp-usage]
!WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wopenmp-usage]
!ERROR: 'z' appears in more than one COPYPRIVATE clause on the END SINGLE directive
!ERROR: At most one NOWAIT clause can appear on the SINGLE directive
!$omp end single copyprivate(x, z) copyprivate(z) nowait
@@ -73,9 +73,9 @@ program single
!ERROR: NOWAIT clause must not be used with COPYPRIVATE clause on the SINGLE directive
!$omp single copyprivate(x) nowait copyprivate(y) copyprivate(z)
print *, x
!WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wopen-mp-usage]
!WARNING: The COPYPRIVATE clause with 'y' is already used on the SINGLE directive [-Wopen-mp-usage]
!WARNING: The COPYPRIVATE clause with 'z' is already used on the SINGLE directive [-Wopen-mp-usage]
!WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wopenmp-usage]
!WARNING: The COPYPRIVATE clause with 'y' is already used on the SINGLE directive [-Wopenmp-usage]
!WARNING: The COPYPRIVATE clause with 'z' is already used on the SINGLE directive [-Wopenmp-usage]
!ERROR: At most one NOWAIT clause can appear on the SINGLE directive
!$omp end single copyprivate(x, y, z) nowait
end program

View File

@@ -39,19 +39,19 @@ subroutine bar(b1, b2, b3)
type(c_ptr), pointer :: b2
type(c_ptr), value :: b3
!WARNING: Variable 'c' in IS_DEVICE_PTR clause must be a dummy argument. This semantic check is deprecated from OpenMP 5.2 and later. [-Wopen-mp-usage]
!WARNING: Variable 'c' in IS_DEVICE_PTR clause must be a dummy argument. This semantic check is deprecated from OpenMP 5.2 and later. [-Wopenmp-usage]
!$omp target is_device_ptr(c)
y = y + 1
!$omp end target
!WARNING: Variable 'b1' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later. [-Wopen-mp-usage]
!WARNING: Variable 'b1' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later. [-Wopenmp-usage]
!$omp target is_device_ptr(b1)
y = y + 1
!$omp end target
!WARNING: Variable 'b2' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later. [-Wopen-mp-usage]
!WARNING: Variable 'b2' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later. [-Wopenmp-usage]
!$omp target is_device_ptr(b2)
y = y + 1
!$omp end target
!WARNING: Variable 'b3' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later. [-Wopen-mp-usage]
!WARNING: Variable 'b3' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later. [-Wopenmp-usage]
!$omp target is_device_ptr(b3)
y = y + 1
!$omp end target

View File

@@ -1,4 +1,5 @@
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp -Wno-openmp-threadprivate-equivalence
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp -Wno-open-mp-threadprivate-equivalence
! This is a test for an extension to the OpenMP semantics, see https://github.com/llvm/llvm-project/issues/180493

View File

@@ -27,7 +27,7 @@ subroutine omp_target_data
a = arrayB
!$omp end target data
!WARNING: Use of non-C_PTR type 'a' in USE_DEVICE_PTR is deprecated, use USE_DEVICE_ADDR instead [-Wopen-mp-usage]
!WARNING: Use of non-C_PTR type 'a' in USE_DEVICE_PTR is deprecated, use USE_DEVICE_ADDR instead [-Wopenmp-usage]
!$omp target data map(tofrom: a) use_device_ptr(a)
a = 2
!$omp end target data

View File

@@ -135,10 +135,10 @@ TEST(FortranFeaturesTest, CamelCaseToLowerCaseHyphenated) {
"pause");
EXPECT_EQ(
CamelCaseToLowerCaseHyphenated(EnumToString(LanguageFeature::OpenACC)),
"open-acc");
"openacc");
EXPECT_EQ(
CamelCaseToLowerCaseHyphenated(EnumToString(LanguageFeature::OpenMP)),
"open-mp");
"openmp");
EXPECT_EQ(CamelCaseToLowerCaseHyphenated(EnumToString(LanguageFeature::CUDA)),
"cuda");
EXPECT_EQ(CamelCaseToLowerCaseHyphenated(
@@ -451,7 +451,7 @@ TEST(FortranFeaturesTest, CamelCaseToLowerCaseHyphenated) {
"scanning");
EXPECT_EQ(
CamelCaseToLowerCaseHyphenated(EnumToString(UsageWarning::OpenAccUsage)),
"open-acc-usage");
"openacc-usage");
EXPECT_EQ(CamelCaseToLowerCaseHyphenated(
EnumToString(UsageWarning::ProcPointerCompatibility)),
"proc-pointer-compatibility");
@@ -489,7 +489,7 @@ TEST(FortranFeaturesTest, CamelCaseToLowerCaseHyphenated) {
"unused-forall-index");
EXPECT_EQ(
CamelCaseToLowerCaseHyphenated(EnumToString(UsageWarning::OpenMPUsage)),
"open-mp-usage");
"openmp-usage");
EXPECT_EQ(
CamelCaseToLowerCaseHyphenated(EnumToString(UsageWarning::DataLength)),
"data-length");