Skip to content

Commit 23ab4b3

Browse files
committed
Rework IssueNonConformanceWarning
1 parent f3c104e commit 23ab4b3

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,8 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
833833

834834
void AddOmpRequiresToScope(Scope &, WithOmpDeclarative::RequiresFlags,
835835
std::optional<common::OmpMemoryOrderType>);
836-
void IssueNonConformanceWarning(
837-
llvm::omp::Directive D, parser::CharBlock source);
836+
void IssueNonConformanceWarning(llvm::omp::Directive D,
837+
parser::CharBlock source, unsigned emit_from_version);
838838

839839
void CreateImplicitSymbols(const Symbol *symbol);
840840

@@ -1664,10 +1664,9 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
16641664
// TODO others
16651665
break;
16661666
}
1667-
if ((beginDir.v == llvm::omp::Directive::OMPD_master ||
1668-
beginDir.v == llvm::omp::Directive::OMPD_parallel_master) &&
1669-
context_.langOptions().OpenMPVersion >= 52)
1670-
IssueNonConformanceWarning(beginDir.v, beginDir.source);
1667+
if (beginDir.v == llvm::omp::Directive::OMPD_master ||
1668+
beginDir.v == llvm::omp::Directive::OMPD_parallel_master)
1669+
IssueNonConformanceWarning(beginDir.v, beginDir.source, 52);
16711670
ClearDataSharingAttributeObjects();
16721671
ClearPrivateDataSharingAttributeObjects();
16731672
ClearAllocateNames();
@@ -1785,13 +1784,12 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPLoopConstruct &x) {
17851784
default:
17861785
break;
17871786
}
1788-
if ((beginDir.v == llvm::omp::OMPD_master_taskloop ||
1789-
beginDir.v == llvm::omp::OMPD_master_taskloop_simd ||
1790-
beginDir.v == llvm::omp::OMPD_parallel_master_taskloop ||
1791-
beginDir.v == llvm::omp::OMPD_parallel_master_taskloop_simd ||
1792-
beginDir.v == llvm::omp::Directive::OMPD_target_loop) &&
1793-
context_.langOptions().OpenMPVersion >= 52)
1794-
IssueNonConformanceWarning(beginDir.v, beginDir.source);
1787+
if (beginDir.v == llvm::omp::OMPD_master_taskloop ||
1788+
beginDir.v == llvm::omp::OMPD_master_taskloop_simd ||
1789+
beginDir.v == llvm::omp::OMPD_parallel_master_taskloop ||
1790+
beginDir.v == llvm::omp::OMPD_parallel_master_taskloop_simd ||
1791+
beginDir.v == llvm::omp::Directive::OMPD_target_loop)
1792+
IssueNonConformanceWarning(beginDir.v, beginDir.source, 52);
17951793
ClearDataSharingAttributeObjects();
17961794
SetContextAssociatedLoopLevel(GetAssociatedLoopLevelFromClauses(clauseList));
17971795

@@ -2075,9 +2073,7 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPDispatchConstruct &x) {
20752073
}
20762074

20772075
bool OmpAttributeVisitor::Pre(const parser::OpenMPExecutableAllocate &x) {
2078-
if (context_.langOptions().OpenMPVersion >= 52) {
2079-
IssueNonConformanceWarning(llvm::omp::Directive::OMPD_allocate, x.source);
2080-
}
2076+
IssueNonConformanceWarning(llvm::omp::Directive::OMPD_allocate, x.source, 52);
20812077

20822078
PushContext(x.source, llvm::omp::Directive::OMPD_allocate);
20832079
const auto &list{std::get<std::optional<parser::OmpObjectList>>(x.t)};
@@ -3131,11 +3127,16 @@ void OmpAttributeVisitor::AddOmpRequiresToScope(Scope &scope,
31313127
} while (!scopeIter->IsGlobal());
31323128
}
31333129

3134-
void OmpAttributeVisitor::IssueNonConformanceWarning(
3135-
llvm::omp::Directive D, parser::CharBlock source) {
3130+
void OmpAttributeVisitor::IssueNonConformanceWarning(llvm::omp::Directive D,
3131+
parser::CharBlock source, unsigned emit_from_version) {
31363132
std::string warnStr;
31373133
llvm::raw_string_ostream warnStrOS(warnStr);
31383134
unsigned version{context_.langOptions().OpenMPVersion};
3135+
// We only want to emit the warning when the version being used has the
3136+
// directive deprecated
3137+
if (version < emit_from_version) {
3138+
return;
3139+
}
31393140
warnStrOS << "OpenMP directive "
31403141
<< parser::ToUpperCaseLetters(
31413142
llvm::omp::getOpenMPDirectiveName(D, version).str())

0 commit comments

Comments
 (0)