[flang-commits] [flang] [flang] Silence spurious error (PR #106086)

via flang-commits flang-commits at lists.llvm.org
Mon Aug 26 08:03:38 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

<details>
<summary>Changes</summary>

Don't attempt to give an object a default binding label when it shows up in a declaration after it has already been given an explicit binding label in an earlier declaration.

Fixes https://github.com/llvm/llvm-project/issues/106019.

---
Full diff: https://github.com/llvm/llvm-project/pull/106086.diff


2 Files Affected:

- (modified) flang/lib/Semantics/resolve-names.cpp (+3) 
- (modified) flang/test/Semantics/declarations03.f90 (+3) 


``````````diff
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index c0478fd4390076..ec8f854f64d103 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1797,6 +1797,9 @@ void AttrsVisitor::SetBindNameOn(Symbol &symbol) {
     }
     auto last{label->find_last_not_of(" ")};
     label = label->substr(first, last - first + 1);
+  } else if (symbol.GetIsExplicitBindName()) {
+    // don't try to override explicit binding name with default
+    return;
   } else if (ClassifyProcedure(symbol) == ProcedureDefinitionClass::Internal) {
     // BIND(C) does not give an implicit binding label to internal procedures.
     return;
diff --git a/flang/test/Semantics/declarations03.f90 b/flang/test/Semantics/declarations03.f90
index 65b07e7d5c6567..8e6f0a4aaf6bd6 100644
--- a/flang/test/Semantics/declarations03.f90
+++ b/flang/test/Semantics/declarations03.f90
@@ -50,6 +50,9 @@ module m
   !ERROR: BIND_C attribute was already specified on 's5'
   integer, bind(c, name="ss2") :: s5
 
+  integer, bind(c, name="s6explicit") :: s6
+  dimension s6(10) ! caused spurious error
+
 end
 
 subroutine common1()

``````````

</details>


https://github.com/llvm/llvm-project/pull/106086


More information about the flang-commits mailing list