[flang-commits] [flang] [Flang] Diagnose nonvariable STAT= specifiers (PR #219696)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Tue Sep 15 07:06:35 PDT 2026


================
@@ -1620,6 +1620,10 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::CoindexedNamedObject &x) {
                           std::get_if<Expr<SomeInteger>>(&expr->u)}) {
                     if (coarrayRef.stat()) {
                       Say("coindexed reference has multiple STAT= specifiers"_err_en_US);
+                    } else if (!IsVariable(*intExpr)) {
+                      // A parser::Variable may resolve to a nonpointer
+                      // function reference.
+                      Say("STAT= specifier must be a scalar integer variable"_err_en_US);
----------------
eugeneepshteyn wrote:

Please try `SayAt(x.v,`, this will give exact location of STAT. Try this test and add it to this PR's tests:
```fortran
subroutine s()
  real, save :: c[10,20,*]
  real :: r
  r = c[1,2,3, STAT=MASK(2), STAT=MASK(3)]
end subroutine
```
With `SayAt` there should be two messages pointing to the right STAT.

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


More information about the flang-commits mailing list