[flang-commits] [PATCH] D157344: [flang] Foil attempt to READ a NAMELIST with an undefinable member
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue Aug 8 12:02:13 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b8e33822ab3: [flang] Foil attempt to READ a NAMELIST with an undefinable member (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157344/new/
https://reviews.llvm.org/D157344
Files:
flang/lib/Semantics/check-io.cpp
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/resolve40.f90
Index: flang/test/Semantics/resolve40.f90
===================================================================
--- flang/test/Semantics/resolve40.f90
+++ flang/test/Semantics/resolve40.f90
@@ -88,3 +88,11 @@
integer :: nl3
nl2 = 1
end
+
+subroutine s12(x)
+ real, intent(in) :: x
+ namelist /nl/x
+ !ERROR: NAMELIST input group must not contain undefinable item 'x'
+ !BECAUSE: 'x' is an INTENT(IN) dummy argument
+ read(*,nml=nl)
+end
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -5844,6 +5844,7 @@
ApplyImplicitRules(*symbol);
} else if (!ConvertToObjectEntity(*symbol)) {
SayWithDecl(name, *symbol, "'%s' is not a variable"_err_en_US);
+ context().SetError(*groupSymbol);
}
symbol->GetUltimate().set(Symbol::Flag::InNamelist);
details->add_object(*symbol);
Index: flang/lib/Semantics/check-io.cpp
===================================================================
--- flang/lib/Semantics/check-io.cpp
+++ flang/lib/Semantics/check-io.cpp
@@ -1171,11 +1171,23 @@
void IoChecker::CheckNamelist(const Symbol &namelist, common::DefinedIo which,
parser::CharBlock namelistLocation) const {
- const auto &details{namelist.GetUltimate().get<NamelistDetails>()};
- for (const Symbol &object : details.objects()) {
- context_.CheckIndexVarRedefine(namelistLocation, object);
- if (auto *msg{CheckForBadIoType(object, which, namelistLocation)}) {
- evaluate::AttachDeclaration(*msg, namelist);
+ if (!context_.HasError(namelist)) {
+ const auto &details{namelist.GetUltimate().get<NamelistDetails>()};
+ for (const Symbol &object : details.objects()) {
+ context_.CheckIndexVarRedefine(namelistLocation, object);
+ if (auto *msg{CheckForBadIoType(object, which, namelistLocation)}) {
+ evaluate::AttachDeclaration(*msg, namelist);
+ } else if (which == common::DefinedIo::ReadFormatted) {
+ if (auto why{WhyNotDefinable(namelistLocation, namelist.owner(),
+ DefinabilityFlags{}, object)}) {
+ context_
+ .Say(namelistLocation,
+ "NAMELIST input group must not contain undefinable item '%s'"_err_en_US,
+ object.name())
+ .Attach(std::move(*why));
+ context_.SetError(namelist);
+ }
+ }
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157344.548307.patch
Type: text/x-patch
Size: 2518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230808/5d929d40/attachment-0001.bin>
More information about the flang-commits
mailing list