[flang] Fix issues comming from clang-10 warnings
authorJean Perier <jperier@nvidia.com>
Thu, 6 Feb 2020 11:27:36 +0000 (03:27 -0800)
committerJean Perier <jperier@nvidia.com>
Mon, 10 Feb 2020 10:33:06 +0000 (02:33 -0800)
- 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
flang/lib/semantics/mod-file.cpp
flang/lib/semantics/resolve-labels.cpp
flang/lib/semantics/resolve-names.cpp
flang/lib/semantics/semantics.cpp
flang/runtime/buffer.h

index faef1ca..a27a935 100644 (file)
@@ -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; }
index 857c52b..1f89c56 100644 (file)
@@ -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);
       }
index 87cacb8..7237627 100644 (file)
@@ -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);
index a964f85..197a32b 100644 (file)
@@ -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<CommonBlockDetails>().objects().empty() &&
         symbol.attrs().test(Attr::BIND_C)) {
index 1f9958e..8c5bece 100644 (file)
@@ -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()
index a7b3184..ec39bac 100644 (file)
@@ -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