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

via flang-commits flang-commits at lists.llvm.org
Mon Aug 26 10:56:40 PDT 2024


Author: Peter Klausler
Date: 2024-08-26T10:56:37-07:00
New Revision: 961a138237947daa5ccabfc87dbfbad8b47146e4

URL: https://github.com/llvm/llvm-project/commit/961a138237947daa5ccabfc87dbfbad8b47146e4
DIFF: https://github.com/llvm/llvm-project/commit/961a138237947daa5ccabfc87dbfbad8b47146e4.diff

LOG: [flang] Silence spurious error (#106086)

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.

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-names.cpp
    flang/test/Semantics/declarations03.f90

Removed: 
    


################################################################################
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()


        


More information about the flang-commits mailing list