[flang-commits] [flang] [flang] Silence spurious errors from benign USE errors (PR #106097)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Aug 26 08:57:15 PDT 2024
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/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.
>From 20a0c5a86506c71d47b144a8970378bc9da12495 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Mon, 26 Aug 2024 08:52:54 -0700
Subject: [PATCH] [flang] Silence spurious errors from benign USE errors
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.
---
flang/lib/Semantics/check-declarations.cpp | 3 +++
flang/test/Semantics/resolve82.f90 | 6 ++++++
2 files changed, 9 insertions(+)
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