[flang-commits] [flang] [flang][semantics] add semantic check that STAT and ERRMSG are not (de)allocated by same statement (PR #164529)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Wed Oct 22 09:02:03 PDT 2025


================
@@ -690,6 +700,20 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) {
           "Object in ALLOCATE must have DEVICE attribute when STREAM option is specified"_err_en_US);
     }
   }
+  if (allocateInfo_.gotStat && allocateInfo_.statVar) {
+    if (const Symbol *symbol{allocateInfo_.statVar->symbol};
+        symbol && *ultimate_ == symbol->GetUltimate()) {
----------------
klausler wrote:

This probably fails with a false positive on `allocate(a(1)%j, stat=a(2)%j)`.  Using just the last symbols won't be enough.

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


More information about the flang-commits mailing list