[flang-commits] [flang] 143be4e - [flang] Silence spurious error (#104821)
via flang-commits
flang-commits at lists.llvm.org
Tue Aug 20 12:04:35 PDT 2024
Author: Peter Klausler
Date: 2024-08-20T12:04:32-07:00
New Revision: 143be4eafc69ed9a0923f44cdf99710cbaa70132
URL: https://github.com/llvm/llvm-project/commit/143be4eafc69ed9a0923f44cdf99710cbaa70132
DIFF: https://github.com/llvm/llvm-project/commit/143be4eafc69ed9a0923f44cdf99710cbaa70132.diff
LOG: [flang] Silence spurious error (#104821)
Don't complain about a local object with an impure final procedure in a
pure subprogram when the local object is a named constant.
Fixes https://github.com/llvm/llvm-project/issues/104796.
Added:
Modified:
flang/lib/Semantics/tools.cpp
flang/test/Semantics/declarations05.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 57d84bde60b43c..845183f2d9b253 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -1558,8 +1558,9 @@ bool IsAutomaticallyDestroyed(const Symbol &symbol) {
return symbol.has<ObjectEntityDetails>() &&
(symbol.owner().kind() == Scope::Kind::Subprogram ||
symbol.owner().kind() == Scope::Kind::BlockConstruct) &&
- (!IsDummy(symbol) || IsIntentOut(symbol)) && !IsPointer(symbol) &&
- !IsSaved(symbol) && !FindCommonBlockContaining(symbol);
+ !IsNamedConstant(symbol) && (!IsDummy(symbol) || IsIntentOut(symbol)) &&
+ !IsPointer(symbol) && !IsSaved(symbol) &&
+ !FindCommonBlockContaining(symbol);
}
const std::optional<parser::Name> &MaybeGetNodeName(
diff --git a/flang/test/Semantics/declarations05.f90 b/flang/test/Semantics/declarations05.f90
index 5144f0b91ab9de..b6dab7aeea0bc8 100644
--- a/flang/test/Semantics/declarations05.f90
+++ b/flang/test/Semantics/declarations05.f90
@@ -29,6 +29,7 @@ pure subroutine test
type(t1) x1
!WARNING: 'x1a' of derived type 't1' does not have a FINAL subroutine for its rank (1)
type(t1), allocatable :: x1a(:)
+ type(t1), parameter :: namedConst = t1() ! ok
!ERROR: 'x2' may not be a local variable in a pure subprogram
!BECAUSE: 'x2' has an impure FINAL procedure 'final'
type(t2) x2
More information about the flang-commits
mailing list