Skip to content

Commit 6ad37a4

Browse files
[Flang][OpenMP] NFC: Trivial changes in OmpCycleChecker (#91024)
Cycle is associated with construct-names and not labels. Change name of a few variables to reflect this. Also add appropriate comment to describe the else case of error checking.
1 parent fc866fd commit 6ad37a4

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ class OmpCycleChecker {
9494

9595
bool Pre(const parser::DoConstruct &dc) {
9696
cycleLevel_--;
97-
const auto &labelName{std::get<0>(std::get<0>(dc.t).statement.t)};
98-
if (labelName) {
99-
labelNamesandLevels_.emplace(labelName.value().ToString(), cycleLevel_);
97+
const auto &constructName{std::get<0>(std::get<0>(dc.t).statement.t)};
98+
if (constructName) {
99+
constructNamesAndLevels_.emplace(
100+
constructName.value().ToString(), cycleLevel_);
100101
}
101102
return true;
102103
}
@@ -105,10 +106,14 @@ class OmpCycleChecker {
105106
std::map<std::string, std::int64_t>::iterator it;
106107
bool err{false};
107108
if (cyclestmt.v) {
108-
it = labelNamesandLevels_.find(cyclestmt.v->source.ToString());
109-
err = (it != labelNamesandLevels_.end() && it->second > 0);
109+
it = constructNamesAndLevels_.find(cyclestmt.v->source.ToString());
110+
err = (it != constructNamesAndLevels_.end() && it->second > 0);
111+
} else {
112+
// If there is no label then the cycle statement is associated with the
113+
// closest enclosing DO. Use its level for the checks.
114+
err = cycleLevel_ > 0;
110115
}
111-
if (cycleLevel_ > 0 || err) {
116+
if (err) {
112117
context_.Say(*cycleSource_,
113118
"CYCLE statement to non-innermost associated loop of an OpenMP DO "
114119
"construct"_err_en_US);
@@ -125,7 +130,7 @@ class OmpCycleChecker {
125130
SemanticsContext &context_;
126131
const parser::CharBlock *cycleSource_;
127132
std::int64_t cycleLevel_;
128-
std::map<std::string, std::int64_t> labelNamesandLevels_;
133+
std::map<std::string, std::int64_t> constructNamesAndLevels_;
129134
};
130135

131136
bool OmpStructureChecker::IsCloselyNestedRegion(const OmpDirectiveSet &set) {

0 commit comments

Comments
 (0)