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

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


Author: Peter Klausler
Date: 2024-08-26T10:57:00-07:00
New Revision: 7cc789bcfba8050eb20ecb8a24508d9a4711dba0

URL: https://github.com/llvm/llvm-project/commit/7cc789bcfba8050eb20ecb8a24508d9a4711dba0
DIFF: https://github.com/llvm/llvm-project/commit/7cc789bcfba8050eb20ecb8a24508d9a4711dba0.diff

LOG: [flang] Silence spurious errors from benign USE errors (#106097)

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.

Added: 
    

Modified: 
    flang/lib/Semantics/check-declarations.cpp
    flang/test/Semantics/resolve82.f90

Removed: 
    


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


        


More information about the flang-commits mailing list