This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add missing check for unresolved name
AbandonedPublic

Authored by tskeith on Apr 9 2020, 11:17 AM.

Details

Summary

The name in an InputItem isn't necessarily resolved if an error occurred, so it needs to be checked.

Diff Detail

Event Timeline

tskeith created this revision.Apr 9 2020, 11:17 AM
Herald added a project: Restricted Project. · View Herald Transcript
jdoerfert added inline comments.Apr 9 2020, 7:57 PM
flang/lib/Semantics/check-io.cpp
300

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...)

tskeith abandoned this revision.Apr 13 2020, 7:44 AM