From 231ff4e6ad992a66988b34ad17b5df6513d3a5ed Mon Sep 17 00:00:00 2001 From: Jean Perier Date: Thu, 6 Feb 2020 03:27:36 -0800 Subject: [PATCH] [flang] Fix issues comming from clang-10 warnings - Remove SubprogramDetails copy ctor - Prevent copies in range based loops over symbols - Remove unsued var Original-commit: flang-compiler/f18@16543d22f74e9421ecb4078818f4c1970bac0a5d Reviewed-on: https://github.com/flang-compiler/f18/pull/972 --- flang/include/flang/semantics/symbol.h | 4 ---- flang/lib/semantics/mod-file.cpp | 4 ++-- flang/lib/semantics/resolve-labels.cpp | 2 +- flang/lib/semantics/resolve-names.cpp | 2 +- flang/lib/semantics/semantics.cpp | 2 +- flang/runtime/buffer.h | 1 - 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/flang/include/flang/semantics/symbol.h b/flang/include/flang/semantics/symbol.h index faef1ca..a27a935 100644 --- a/flang/include/flang/semantics/symbol.h +++ b/flang/include/flang/semantics/symbol.h @@ -52,10 +52,6 @@ private: class SubprogramDetails { public: - SubprogramDetails() {} - SubprogramDetails(const SubprogramDetails &that) - : dummyArgs_{that.dummyArgs_}, result_{that.result_} {} - bool isFunction() const { return result_ != nullptr; } bool isInterface() const { return isInterface_; } void set_isInterface(bool value = true) { isInterface_ = value; } diff --git a/flang/lib/semantics/mod-file.cpp b/flang/lib/semantics/mod-file.cpp index 857c52b..1f89c56 100644 --- a/flang/lib/semantics/mod-file.cpp +++ b/flang/lib/semantics/mod-file.cpp @@ -915,10 +915,10 @@ void SubprogramSymbolCollector::DoType(const DeclTypeSpec *type) { if (const DerivedTypeSpec * extends{typeSymbol.GetParentTypeSpec()}) { DoSymbol(extends->name(), extends->typeSymbol()); } - for (const auto pair : derived->parameters()) { + for (const auto &pair : derived->parameters()) { DoParamValue(pair.second); } - for (const auto pair : *typeSymbol.scope()) { + for (const auto &pair : *typeSymbol.scope()) { const Symbol &comp{*pair.second}; DoSymbol(comp); } diff --git a/flang/lib/semantics/resolve-labels.cpp b/flang/lib/semantics/resolve-labels.cpp index 87cacb8..7237627 100644 --- a/flang/lib/semantics/resolve-labels.cpp +++ b/flang/lib/semantics/resolve-labels.cpp @@ -824,7 +824,7 @@ void CheckBranchesIntoDoBody(const SourceStmtList &branches, if (HasScope(branchTarget.proxyForScope)) { const auto &fromPosition{branch.parserCharBlock}; const auto &toPosition{branchTarget.parserCharBlock}; - for (const auto body : loopBodies) { + for (const auto &body : loopBodies) { if (!InBody(fromPosition, body) && InBody(toPosition, body)) { context.Say(fromPosition, "branch into loop body from outside"_en_US) .Attach(body.first, "the loop branched into"_en_US); diff --git a/flang/lib/semantics/resolve-names.cpp b/flang/lib/semantics/resolve-names.cpp index a964f85..197a32b 100644 --- a/flang/lib/semantics/resolve-names.cpp +++ b/flang/lib/semantics/resolve-names.cpp @@ -4099,7 +4099,7 @@ void DeclarationVisitor::SetSaveAttr(Symbol &symbol) { // Check types of common block objects, now that they are known. void DeclarationVisitor::CheckCommonBlocks() { // check for empty common blocks - for (const auto pair : currScope().commonBlocks()) { + for (const auto &pair : currScope().commonBlocks()) { const auto &symbol{*pair.second}; if (symbol.get().objects().empty() && symbol.attrs().test(Attr::BIND_C)) { diff --git a/flang/lib/semantics/semantics.cpp b/flang/lib/semantics/semantics.cpp index 1f9958e..8c5bece 100644 --- a/flang/lib/semantics/semantics.cpp +++ b/flang/lib/semantics/semantics.cpp @@ -294,7 +294,7 @@ void Semantics::DumpSymbols(std::ostream &os) { void Semantics::DumpSymbolsSources(std::ostream &os) const { NameToSymbolMap symbols; GetSymbolNames(context_.globalScope(), symbols); - for (const auto pair : symbols) { + for (const auto &pair : symbols) { const Symbol &symbol{pair.second}; if (auto sourceInfo{cooked_.GetSourcePositionRange(symbol.name())}) { os << symbol.name().ToString() << ": " << sourceInfo->first.file.path() diff --git a/flang/runtime/buffer.h b/flang/runtime/buffer.h index a7b3184..ec39bac 100644 --- a/flang/runtime/buffer.h +++ b/flang/runtime/buffer.h @@ -66,7 +66,6 @@ public: } else { // [cde........ab] -> [abcde........] auto n{start_ + length_ - size_}; // 3 for cde - auto gap{size_ - length_}; // 13 - 5 = 8 RUNTIME_CHECK(handler, length_ >= n); std::memmove(buffer_ + n, buffer_ + start_, length_ - n); // cdeab LeftShiftBufferCircularly(buffer_, length_, n); // abcde -- 2.7.4