[flang-commits] [flang] [Flang] Extra check for character length in pointer allocation (PR #95145)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Jun 17 11:22:02 PDT 2024


================
@@ -0,0 +1,24 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! Check for semantic errors in ALLOCATE statements
+
+! C934
+! If type-spec appears, it shall specify a type with which each
+! allocate-object is type compatible.
+! Issue #78939: allocatable object has a non-defined character length.
+! This should also be an error when the length is defined by a parameter
+! in a module.
+
+module m1
+  integer::nn=1
+  integer,parameter::np=1
+end module m1
+
+program main
+  use m1
+  character(nn),pointer::cns
+  character(np),pointer::c1s
+  !ERROR: Character length of allocatable object in ALLOCATE must be the same as the type-spec
----------------
klausler wrote:

This error should not be a compilation-time error.  I pointed this out in an earlier comment.  I don't know how to explain it any more clearly.  Do not emit an error here.

https://github.com/llvm/llvm-project/pull/95145


More information about the flang-commits mailing list