[flang-commits] [flang] b52728d - [flang] Silence warning when inappropriate (#105867)
via flang-commits
flang-commits at lists.llvm.org
Mon Aug 26 10:53:19 PDT 2024
Author: Peter Klausler
Date: 2024-08-26T10:53:17-07:00
New Revision: b52728d89bb44ec59fa60ec02e1a9cbdb86037e1
URL: https://github.com/llvm/llvm-project/commit/b52728d89bb44ec59fa60ec02e1a9cbdb86037e1
DIFF: https://github.com/llvm/llvm-project/commit/b52728d89bb44ec59fa60ec02e1a9cbdb86037e1.diff
LOG: [flang] Silence warning when inappropriate (#105867)
When a function returns an array, using an element of that array is an
actual argument in a procedure reference with an implicit interface
should suffice to avoid a warning about an undefined function result.
Added:
Modified:
flang/lib/Semantics/check-call.cpp
flang/test/Semantics/undef-result01.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 4708d51d3af4dd..c7ec8733655648 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -56,6 +56,10 @@ static void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
"%VAL argument must be a scalar numeric or logical expression"_err_en_US);
}
if (const auto *expr{arg.UnwrapExpr()}) {
+ if (const Symbol * base{GetFirstSymbol(*expr)};
+ base && IsFunctionResult(*base)) {
+ context.NoteDefinedSymbol(*base);
+ }
if (IsBOZLiteral(*expr)) {
messages.Say("BOZ argument requires an explicit interface"_err_en_US);
} else if (evaluate::IsNullPointer(*expr)) {
@@ -79,10 +83,6 @@ static void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
messages.Say(
"VOLATILE argument requires an explicit interface"_err_en_US);
}
- if (const Symbol & base{named->GetFirstSymbol()};
- IsFunctionResult(base)) {
- context.NoteDefinedSymbol(base);
- }
} else if (auto argChars{characteristics::DummyArgument::FromActual(
"actual argument", *expr, context.foldingContext(),
/*forImplicitInterface=*/true)}) {
diff --git a/flang/test/Semantics/undef-result01.f90 b/flang/test/Semantics/undef-result01.f90
index bf6af11a8d7b92..08e7fe1e448998 100644
--- a/flang/test/Semantics/undef-result01.f90
+++ b/flang/test/Semantics/undef-result01.f90
@@ -148,3 +148,8 @@ function defdByAssociate()
s = 1.
end associate
end
+
+function defdByElementArgToImplicit() result(r)
+ real r(1)
+ call define(r(1))
+end
More information about the flang-commits
mailing list