Skip to content

Commit 86dc6a7

Browse files
Merge branch '3-acc-common' into 2-acc-common
2 parents adf6b5f + 258050f commit 86dc6a7

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

flang/include/flang/Semantics/scope.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ class Scope {
8686
CHECK(parent_ != this);
8787
return *parent_;
8888
}
89+
90+
mapType &commonBlocks() { return commonBlocks_; }
91+
const mapType &commonBlocks() const { return commonBlocks_; }
92+
93+
mapType &commonBlockUses() { return commonBlockUses_; }
94+
const mapType &commonBlockUses() const { return commonBlockUses_; }
95+
8996
Kind kind() const { return kind_; }
9097
bool IsGlobal() const { return kind_ == Kind::Global; }
9198
bool IsIntrinsicModules() const { return kind_ == Kind::IntrinsicModules; }
@@ -186,11 +193,8 @@ class Scope {
186193
// Cray pointers are saved as map of pointee name -> pointer symbol
187194
const mapType &crayPointers() const { return crayPointers_; }
188195
void add_crayPointer(const SourceName &, Symbol &);
189-
mapType &commonBlocks() { return commonBlocks_; }
190-
const mapType &commonBlocks() const { return commonBlocks_; }
191196
Symbol &MakeCommonBlock(SourceName, SourceName location);
192197
bool AddCommonBlockUse(const SourceName &name, Symbol &cbSymbol);
193-
mapType &commonBlockUses() { return commonBlockUses_; }
194198

195199
// Find COMMON block that is declared in the current scope
196200
Symbol *FindCommonBlock(const SourceName &name) const {

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,13 +1730,12 @@ void AccAttributeVisitor::Post(const parser::Name &name) {
17301730

17311731
Symbol *AccAttributeVisitor::ResolveAccCommonBlockName(
17321732
const parser::Name *name) {
1733-
if (!name) {
1734-
return nullptr;
1735-
}
1736-
if (auto *cb{
1737-
GetContext().scope.FindCommonBlockInVisibleScopes(name->source)}) {
1738-
name->symbol = cb;
1739-
return cb;
1733+
if (name) {
1734+
if (Symbol *cb{
1735+
GetContext().scope.FindCommonBlockInVisibleScopes(name->source)}) {
1736+
name->symbol = cb;
1737+
return cb;
1738+
}
17401739
}
17411740
return nullptr;
17421741
}

flang/lib/Semantics/resolve-names.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3633,9 +3633,9 @@ void ModuleVisitor::Post(const parser::UseStmt &x) {
36333633
if (!currScope().FindCommonBlockInVisibleScopes(name)) {
36343634
// Make a symbol, but don't add it to the Scope, since it needs to
36353635
// be added to the USE-associated COMMON blocks
3636-
Symbol *localCB{&currScope().MakeSymbol(
3636+
Symbol &localCB{currScope().MakeSymbol(
36373637
name, symbol->attrs(), UseDetails{name, symbol->GetUltimate()})};
3638-
currScope().AddCommonBlockUse(name, *localCB);
3638+
currScope().AddCommonBlockUse(name, localCB);
36393639
}
36403640
}
36413641
// Go through the list of USE-associated COMMON block symbols in the module
@@ -3644,9 +3644,9 @@ void ModuleVisitor::Post(const parser::UseStmt &x) {
36443644
for (const auto &[name, symbol] : useModuleScope_->commonBlockUses()) {
36453645
// Make a symbol, but don't add it to the Scope, since it needs to
36463646
// be added to the USE-associated COMMON blocks
3647-
Symbol *localCB{&currScope().MakeSymbol(
3647+
Symbol &localCB{currScope().MakeSymbol(
36483648
name, symbol->attrs(), UseDetails{name, symbol->GetUltimate()})};
3649-
currScope().AddCommonBlockUse(name, *localCB);
3649+
currScope().AddCommonBlockUse(name, localCB);
36503650
}
36513651
useModuleScope_ = nullptr;
36523652
}

0 commit comments

Comments
 (0)