The name in an InputItem isn't necessarily resolved if an error occurred, so it needs to be checked.
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| flang/lib/Semantics/check-io.cpp | ||
|---|---|---|
| 300 | For a follow up maybe: void IoChecker::Enter(const parser::InputItem &spec) {
flags_.set(Flag::DataList);
const parser::Variable * var{std::get_if<parser::Variable>(&spec.u)});
if (!var)
return;
const parser::Name &name{GetLastName(*var)};
if (!name.symbol)
return;
auto *details{name.symbol->detailsIf<ObjectEntityDetails>()};
if (!details)
return;
// TODO: Determine if this check is needed at all, and if so, replace
// the false subcondition with a check for a whole array. Otherwise,
// the check incorrectly flags array element and section references.
if (details->IsAssumedSize() && false) {
// This check may be superseded by C928 or C1002.
context_.Say(name.source,
"'%s' must not be a whole assumed size array"_err_en_US,
name.source); // C1231
}
}(Notwithstanding the && false...) | |
For a follow up maybe:
Style: What about early exits? At level 5 this really makes a difference:
void IoChecker::Enter(const parser::InputItem &spec) { flags_.set(Flag::DataList); const parser::Variable * var{std::get_if<parser::Variable>(&spec.u)}); if (!var) return; const parser::Name &name{GetLastName(*var)}; if (!name.symbol) return; auto *details{name.symbol->detailsIf<ObjectEntityDetails>()}; if (!details) return; // TODO: Determine if this check is needed at all, and if so, replace // the false subcondition with a check for a whole array. Otherwise, // the check incorrectly flags array element and section references. if (details->IsAssumedSize() && false) { // This check may be superseded by C928 or C1002. context_.Say(name.source, "'%s' must not be a whole assumed size array"_err_en_US, name.source); // C1231 } }(Notwithstanding the && false...)