[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


================
@@ -115,10 +115,18 @@ static void CheckTeamType(
 static void CheckTeamStat(
     SemanticsContext &context, const parser::ImageSelectorSpec::Stat &stat) {
   const auto &var{parser::UnwrapRef<parser::Variable>(stat)};
+  auto at{parser::FindSourceLocation(var)};
   if (parser::GetCoindexedNamedObject(var)) {
     context.Say(parser::FindSourceLocation(var), // C931
         "Image selector STAT variable must not be a coindexed "
         "object"_err_en_US);
+  } else if (const auto *expr{GetExpr(context, var)}) {
+    if (auto type{expr->GetType()};
+        type && type->category() == TypeCategory::Integer &&
+        type->kind() < 2 && context.ShouldWarn(common::LanguageFeature::StatKind)) { // F2023 9.7.4 p1
+      context.Say(at,
+          "The stat-variable must have an integer kind of at least 16-bit"_warn_en_US);
----------------
eugeneepshteyn wrote:

Nit: the standard only recommends this ("should"), and states it as a decimal exponent range rather than a bit width. Maybe "STAT= variable should have a decimal exponent range of at least four"? For the same reason, the `! violates F2023 9.7.4` comments in the test overstate it.

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


More information about the flang-commits mailing list