[flang-commits] [PATCH] D156753: [flang] More compile-time error checking for null implied DO loops in array constructors

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue Aug 1 09:26:02 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c446da5565f: [flang] More compile-time error checking for null implied DO loops in array… (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156753/new/

https://reviews.llvm.org/D156753

Files:
  flang/lib/Semantics/expression.cpp
  flang/test/Semantics/array-constr-len.f90


Index: flang/test/Semantics/array-constr-len.f90
===================================================================
--- flang/test/Semantics/array-constr-len.f90
+++ flang/test/Semantics/array-constr-len.f90
@@ -10,5 +10,6 @@
   print *, [(s(1:j),j=1,0)]
   print *, [(s(1:1),j=1,0)] ! ok
   print *, [character(2)::(s(1:n),j=1,0)] ! ok
-  print *, [character(n)::(s(1:n),j=1,0)] ! ok
+  !ERROR: Array constructor implied DO loop has no iterations and indeterminate character length
+  print *, [character(n)::(s(1:n),j=1,0)]
 end
Index: flang/lib/Semantics/expression.cpp
===================================================================
--- flang/lib/Semantics/expression.cpp
+++ flang/lib/Semantics/expression.cpp
@@ -1510,8 +1510,8 @@
     return std::nullopt;
   }
   bool NeedLength() const {
-    return !explicitType_ && type_ &&
-        type_->category() == TypeCategory::Character && !LengthIfGood();
+    return type_ && type_->category() == TypeCategory::Character &&
+        !LengthIfGood();
   }
   void Push(MaybeExpr &&);
   void Add(const parser::AcValue::Triplet &);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156753.546091.patch
Type: text/x-patch
Size: 1090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230801/fd1bb1ca/attachment.bin>


More information about the flang-commits mailing list