[flang-commits] [flang] [flang] Silence spurious errors from benign USE errors (PR #106097)

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

<details>
<summary>Changes</summary>

When USE association encounters a conflict that can't be resolved, it produces a "UseError" symbol that will trigger an error message if that symbol is ever actually used. UseError symbols that aren't used are benign.

Ensure that UseError symbols don't run the gamut of declaration checking.  They were getting through, and could lead to spurious error messages.

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

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


2 Files Affected:

- (modified) flang/lib/Semantics/check-declarations.cpp (+3) 
- (modified) flang/test/Semantics/resolve82.f90 (+6) 


``````````diff
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index de3fa8794caedf..734c34276b13b9 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -256,6 +256,9 @@ static bool IsBlockData(const Symbol &symbol) {
 }
 
 void CheckHelper::Check(const Symbol &symbol) {
+  if (symbol.has<UseErrorDetails>()) {
+    return;
+  }
   if (symbol.name().size() > common::maxNameLen &&
       &symbol == &symbol.GetUltimate()) {
     if (context_.ShouldWarn(common::LanguageFeature::LongNames)) {
diff --git a/flang/test/Semantics/resolve82.f90 b/flang/test/Semantics/resolve82.f90
index 88339742efdb36..989ce1d837c705 100644
--- a/flang/test/Semantics/resolve82.f90
+++ b/flang/test/Semantics/resolve82.f90
@@ -34,6 +34,7 @@ end function procFunc
   real y
   common /blk/ y
   protected y
+  logical,protected,external,pointer :: z
 
 contains
 
@@ -60,3 +61,8 @@ subroutine testProcDecl(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11)
     end subroutine testProcDecl
 
 end module m
+
+subroutine subb()
+  !Ensure no spurious error from a benign UseError
+  use m, testProcDecl=>z
+end

``````````

</details>


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


More information about the flang-commits mailing list