[flang-commits] [flang] 5e8094b - [flang] Don't inherit ELEMENTAL attribute from intrinsics for TBP bindings
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Tue Aug 9 08:09:43 PDT 2022
Author: Peter Klausler
Date: 2022-08-09T08:09:32-07:00
New Revision: 5e8094bae50b1dd533ca0a20693d28a58b9c0d59
URL: https://github.com/llvm/llvm-project/commit/5e8094bae50b1dd533ca0a20693d28a58b9c0d59
DIFF: https://github.com/llvm/llvm-project/commit/5e8094bae50b1dd533ca0a20693d28a58b9c0d59.diff
LOG: [flang] Don't inherit ELEMENTAL attribute from intrinsics for TBP bindings
Type-bound procedure bindings that specify intrinsic procedures as their
interfaces should not acquire the ELEMENTAL attribute from the purposes
of compatibility checking between inherited bindings and their overrides
in extended derived types.
Differential Revision: https://reviews.llvm.org/D131104
Added:
Modified:
flang/lib/Evaluate/characteristics.cpp
flang/lib/Evaluate/tools.cpp
flang/lib/Semantics/check-declarations.cpp
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp
index 89d794f2c0819..cc092cd1a46d7 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -530,15 +530,17 @@ static std::optional<Procedure> CharacterizeProcedure(
[&](const semantics::ProcBindingDetails &binding) {
if (auto result{CharacterizeProcedure(
binding.symbol(), context, seenProcs)}) {
+ if (binding.symbol().attrs().test(semantics::Attr::INTRINSIC)) {
+ result->attrs.reset(Procedure::Attr::Elemental);
+ }
if (!symbol.attrs().test(semantics::Attr::NOPASS)) {
auto passName{binding.passName()};
for (auto &dummy : result->dummyArguments) {
if (!passName || dummy.name.c_str() == *passName) {
dummy.pass = true;
- return result;
+ break;
}
}
- DIE("PASS argument missing");
}
return result;
} else {
diff --git a/flang/lib/Evaluate/tools.cpp b/flang/lib/Evaluate/tools.cpp
index 84417cd18418f..85aadeb3efcd9 100644
--- a/flang/lib/Evaluate/tools.cpp
+++ b/flang/lib/Evaluate/tools.cpp
@@ -1247,7 +1247,8 @@ bool IsElementalProcedure(const Symbol &original) {
IsElementalProcedure(*procInterface);
}
} else if (const auto *details{symbol.detailsIf<ProcBindingDetails>()}) {
- return IsElementalProcedure(details->symbol());
+ return !details->symbol().attrs().test(Attr::INTRINSIC) &&
+ IsElementalProcedure(details->symbol());
} else if (!IsProcedure(symbol)) {
return false;
}
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 8c63a74b82116..3a506c9641fc9 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -1661,7 +1661,7 @@ void CheckHelper::CheckProcBinding(
return;
}
if (!IsElementalProcedure(binding.symbol()) &&
- IsElementalProcedure(overriddenBinding->symbol())) {
+ IsElementalProcedure(*overridden)) {
SayWithDeclaration(*overridden,
"A type-bound procedure and its override must both, or neither, be ELEMENTAL"_err_en_US);
return;
@@ -1674,7 +1674,7 @@ void CheckHelper::CheckProcBinding(
: "A passed-argument type-bound procedure may not override a NOPASS procedure"_err_en_US);
} else {
const auto *bindingChars{Characterize(binding.symbol())};
- const auto *overriddenChars{Characterize(overriddenBinding->symbol())};
+ const auto *overriddenChars{Characterize(*overridden)};
if (bindingChars && overriddenChars) {
if (isNopass) {
if (!bindingChars->CanOverride(*overriddenChars, std::nullopt)) {
More information about the flang-commits
mailing list