From b78109e22ed14d92a01cb2fff07d1673e63c513b Mon Sep 17 00:00:00 2001 From: Tim Keith Date: Fri, 26 Oct 2018 11:57:08 -0700 Subject: [PATCH] [flang] Address review comments Original-commit: flang-compiler/f18@c3597a1984811900ef8da55f15374417373f5492 Reviewed-on: https://github.com/flang-compiler/f18/pull/218 --- flang/lib/semantics/resolve-names.cc | 17 ++++++++++------- flang/lib/semantics/symbol.cc | 6 +++--- flang/lib/semantics/symbol.h | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/flang/lib/semantics/resolve-names.cc b/flang/lib/semantics/resolve-names.cc index b379bfe6..d547fd0 100644 --- a/flang/lib/semantics/resolve-names.cc +++ b/flang/lib/semantics/resolve-names.cc @@ -263,7 +263,7 @@ public: protected: void PushScope(); void PopScope(); - void ClearScopes() { implicitRules_.reset(nullptr); } + void ClearScopes() { implicitRules_.reset(); } private: // implicit rules in effect for current scope @@ -1636,7 +1636,7 @@ bool InterfaceVisitor::Pre(const parser::GenericSpec &x) { EraseSymbol(*genericName); genericSymbol_ = &MakeSymbol(*genericName); genericSymbol_->set_details(details); - } else if (!genericSymbol_->isSubprogram()) { + } else if (!genericSymbol_->IsSubprogram()) { SayAlreadyDeclared(*genericName, *genericSymbol_); EraseSymbol(*genericName); genericSymbol_ = nullptr; @@ -1862,7 +1862,7 @@ bool SubprogramVisitor::Pre(const parser::Suffix &suffix) { } bool HasModulePrefix(const std::list &prefixes) { - for (auto &prefix : prefixes) { + for (const auto &prefix : prefixes) { if (std::holds_alternative(prefix.u)) { return true; } @@ -1902,7 +1902,8 @@ void SubprogramVisitor::Post(const parser::FunctionSubprogram &) { bool SubprogramVisitor::Pre(const parser::InterfaceBody::Subroutine &x) { const auto &name{std::get( std::get>(x.t).statement.t)}; - return BeginSubprogram(name, Symbol::Flag::Subroutine, false, std::nullopt); + return BeginSubprogram( + name, Symbol::Flag::Subroutine, /*hasModulePrefix*/ false, std::nullopt); } void SubprogramVisitor::Post(const parser::InterfaceBody::Subroutine &) { EndSubprogram(); @@ -1910,7 +1911,8 @@ void SubprogramVisitor::Post(const parser::InterfaceBody::Subroutine &) { bool SubprogramVisitor::Pre(const parser::InterfaceBody::Function &x) { const auto &name{std::get( std::get>(x.t).statement.t)}; - return BeginSubprogram(name, Symbol::Flag::Function, false, std::nullopt); + return BeginSubprogram( + name, Symbol::Flag::Function, /*hasModulePrefix*/ false, std::nullopt); } void SubprogramVisitor::Post(const parser::InterfaceBody::Function &) { EndSubprogram(); @@ -1984,7 +1986,7 @@ bool SubprogramVisitor::BeginSubprogram(const parser::Name &name, } if (hasModulePrefix && !inInterfaceBlock()) { auto *symbol{FindSymbol(name.source)}; - if (!symbol || !symbol->IsSeparateMp()) { + if (!symbol || !symbol->IsSeparateModuleProc()) { Say(name.source, "'%s' was not declared a separate module procedure"_err_en_US); return false; @@ -2016,7 +2018,8 @@ bool SubprogramVisitor::Pre(const parser::SeparateModuleSubprogram &x) { std::get>(x.t).statement.v}; const auto &subpPart{ std::get>(x.t)}; - return BeginSubprogram(name, Symbol::Flag::Subroutine, true, subpPart); + return BeginSubprogram( + name, Symbol::Flag::Subroutine, /*hasModulePrefix*/ true, subpPart); } void SubprogramVisitor::Post(const parser::SeparateModuleSubprogram &) { diff --git a/flang/lib/semantics/symbol.cc b/flang/lib/semantics/symbol.cc index f2bf030..303497b 100644 --- a/flang/lib/semantics/symbol.cc +++ b/flang/lib/semantics/symbol.cc @@ -222,13 +222,13 @@ void Symbol::SetType(const DeclTypeSpec &type) { details_); } -bool Symbol::isSubprogram() const { +bool Symbol::IsSubprogram() const { return std::visit( common::visitors{ [](const SubprogramDetails &) { return true; }, [](const SubprogramNameDetails &) { return true; }, [](const GenericDetails &) { return true; }, - [](const UseDetails &x) { return x.symbol().isSubprogram(); }, + [](const UseDetails &x) { return x.symbol().IsSubprogram(); }, [](const auto &) { return false; }, }, details_); @@ -246,7 +246,7 @@ bool Symbol::HasExplicitInterface() const { details_); } -bool Symbol::IsSeparateMp() const { +bool Symbol::IsSeparateModuleProc() const { if (attrs().test(Attr::MODULE)) { if (auto *details{detailsIf()}) { return details->isInterface(); diff --git a/flang/lib/semantics/symbol.h b/flang/lib/semantics/symbol.h index 48a1b72..3364325 100644 --- a/flang/lib/semantics/symbol.h +++ b/flang/lib/semantics/symbol.h @@ -362,9 +362,9 @@ public: const DeclTypeSpec *GetType() const; void SetType(const DeclTypeSpec &); - bool isSubprogram() const; + bool IsSubprogram() const; bool HasExplicitInterface() const; - bool IsSeparateMp() const; + bool IsSeparateModuleProc() const; bool operator==(const Symbol &that) const { return this == &that; } bool operator!=(const Symbol &that) const { return this != &that; } -- 2.7.4