[flang-commits] [flang] [flang][Semantics] Adding check integer kind on STAT= specifier #230463 (PR #231103)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Mon Oct 12 18:46:40 PDT 2026


================
@@ -0,0 +1,27 @@
+! RUN: %flang -fsyntax-only -pedantic %s 2>&1 | FileCheck %s
+
+program stat_test
+  use iso_c_binding
+  use iso_fortran_env
+  integer :: coarray[*]
+  type(event_type) :: e[*]
+  integer(C_INT8_T) :: myint8
+  integer(C_INT16_T) :: myint16
+ 
+  ! CHECK: warning:  The stat-variable must have an integer kind of at least 16-bit
+  coarray[1, stat=myint8] = 0 ! violates F2023 9.7.4
+  
+  ! CHECK: warning: The stat-variable must have an integer kind of at least 16-bit
+  sync all(stat=myint8) ! violates F2023 9.7.4
+  
+  ! CHECK: warning: The stat-variable must have an integer kind of at least 16-bit
+  event wait(e, stat=myint8) ! violates F2023 9.7.4
+  
+  ! CHECK-NOT: warning: The stat-variable must have an integer kind of at least 16-bit
----------------
eugeneepshteyn wrote:

(This comment was generated with the help of AI)

Could this use `test_errors.py`, so that each warning is tied to its statement? With three identical `CHECK:` lines, the test passes as long as three such warnings appear anywhere. Once the message goes through `Warn`, something like:

```fortran
!RUN: %python %S/test_errors.py %s %flang_fc1 -Werror -Wstat-kind
program p
  integer(1) :: s1
  integer(2) :: s2
  integer, allocatable :: a(:)
  !WARNING: The stat-variable must have an integer kind of at least 16-bit [-Wstat-kind]
  sync all(stat=s1)
  sync all(stat=s2)
  !WARNING: The stat-variable must have an integer kind of at least 16-bit [-Wstat-kind]
  allocate(a(3), stat=s1)
end program
```

A second file with no annotations, run with `%flang_fc1 -Werror` and with `%flang_fc1 -std=f2018 -Werror`, would check that the warning stays off by default.

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


More information about the flang-commits mailing list