[PATCH] D78685: [flang] Add missing check for unresolved name

Tim Keith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 16:21:14 PDT 2020


tskeith created this revision.
tskeith added reviewers: klausler, PeteSteinfeld.
Herald added a reviewer: DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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

Fixes https://bugs.llvm.org/show_bug.cgi?id=45477


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78685

Files:
  flang/lib/Semantics/check-io.cpp


Index: flang/lib/Semantics/check-io.cpp
===================================================================
--- flang/lib/Semantics/check-io.cpp
+++ flang/lib/Semantics/check-io.cpp
@@ -283,15 +283,17 @@
   flags_.set(Flag::DataList);
   if (const parser::Variable * var{std::get_if<parser::Variable>(&spec.u)}) {
     const parser::Name &name{GetLastName(*var)};
-    if (auto *details{name.symbol->detailsIf<ObjectEntityDetails>()}) {
-      // 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
+    if (name.symbol) {
+      if (auto *details{name.symbol->detailsIf<ObjectEntityDetails>()}) {
+        // 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
+        }
       }
     }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78685.259423.patch
Type: text/x-patch
Size: 1540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200422/3f05d678/attachment.bin>


More information about the llvm-commits mailing list