Skip to content

[flang] Silence spurious errors from benign USE errors #106097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

klausler
Copy link
Contributor

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

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 llvm#106020.
@klausler klausler requested a review from vdonaldson August 26, 2024 15:57
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Aug 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 26, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

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

@klausler klausler merged commit 7cc789b into llvm:main Aug 26, 2024
11 checks passed
@klausler klausler deleted the bug106020 branch August 26, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Flang] Compilation error when rename-list is used in use statement
3 participants