Skip to content

Commit 7672b0f

Browse files
committed
address feedback
1 parent 3e276d9 commit 7672b0f

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ template <typename T> class DirectiveAttributeVisitor {
6161
defaultMap;
6262

6363
std::optional<Symbol::Flag> FindSymbolWithDSA(const Symbol &symbol) {
64-
auto it{objectWithDSA.find(&symbol)};
65-
if (it != objectWithDSA.end()) {
66-
return std::make_optional(it->second);
64+
if (auto it{objectWithDSA.find(&symbol)}; it != objectWithDSA.end()) {
65+
return it->second;
6766
}
6867
return std::nullopt;
6968
}
@@ -83,10 +82,9 @@ template <typename T> class DirectiveAttributeVisitor {
8382
}
8483
void PushContext(const parser::CharBlock &source, T dir, Scope &scope) {
8584
if constexpr (std::is_same_v<T, llvm::acc::Directive>) {
86-
bool wasEmpty{dirContext_.empty()};
8785
dirContext_.emplace_back(source, dir, scope);
88-
if (!wasEmpty) {
89-
std::size_t lastIndex{dirContext_.size() - 1};
86+
if (std::size_t size{dirContext_.size()}; size > 1) {
87+
std::size_t lastIndex{size - 1};
9088
dirContext_[lastIndex].defaultDSA =
9189
dirContext_[lastIndex - 1].defaultDSA;
9290
}
@@ -128,7 +126,7 @@ template <typename T> class DirectiveAttributeVisitor {
128126
return false;
129127
}
130128

131-
bool WithinContstruct() {
129+
bool WithinConstruct() {
132130
return !dirContext_.empty() && GetContext().withinConstruct;
133131
}
134132

@@ -1602,7 +1600,7 @@ void AccAttributeVisitor::Post(const parser::AccDefaultClause &x) {
16021600
// and adjust the symbol for each Name if necessary
16031601
void AccAttributeVisitor::Post(const parser::Name &name) {
16041602
auto *symbol{name.symbol};
1605-
if (symbol && WithinContstruct()) {
1603+
if (symbol && WithinConstruct()) {
16061604
symbol = &symbol->GetUltimate();
16071605
if (!symbol->owner().IsDerivedType() && !symbol->has<ProcEntityDetails>() &&
16081606
!symbol->has<SubprogramDetails>() && !IsObjectWithVisibleDSA(*symbol)) {
@@ -1988,7 +1986,7 @@ void OmpAttributeVisitor::ResolveSeqLoopIndexInParallelOrTaskConstruct(
19881986
// till OpenMP-5.0 standard.
19891987
// In above both cases we skip the privatization of iteration variables.
19901988
bool OmpAttributeVisitor::Pre(const parser::DoConstruct &x) {
1991-
if (WithinContstruct()) {
1989+
if (WithinConstruct()) {
19921990
llvm::SmallVector<const parser::Name *> ivs;
19931991
if (x.IsDoNormal()) {
19941992
const parser::Name *iv{GetLoopIndex(x)};
@@ -2714,7 +2712,7 @@ void OmpAttributeVisitor::CreateImplicitSymbols(const Symbol *symbol) {
27142712
void OmpAttributeVisitor::Post(const parser::Name &name) {
27152713
auto *symbol{name.symbol};
27162714

2717-
if (symbol && WithinContstruct()) {
2715+
if (symbol && WithinConstruct()) {
27182716
if (IsPrivatizable(symbol) && !IsObjectWithDSA(*symbol)) {
27192717
// TODO: create a separate function to go through the rules for
27202718
// predetermined, explicitly determined, and implicitly

flang/test/Semantics/OpenACC/acc-parallel.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,4 @@ subroutine acc_parallel_default_none
221221
end do
222222
!$acc end parallel
223223
!$acc end data
224-
end subroutine acc_parallel_default_none
224+
end subroutine acc_parallel_default_none

0 commit comments

Comments
 (0)