@@ -64,11 +64,15 @@ class CriticalBodyEnforce {
6464};
6565
6666template <typename T>
67- static void CheckTeamType (SemanticsContext &context, const T &x) {
67+ static void CheckTeamType (
68+ SemanticsContext &context, const T &x, bool mustBeVariable = false ) {
6869 if (const auto *expr{GetExpr (context, x)}) {
6970 if (!IsTeamType (evaluate::GetDerivedTypeSpec (expr->GetType ()))) {
7071 context.Say (parser::FindSourceLocation (x), // C1114
7172 " Team value must be of type TEAM_TYPE from module ISO_FORTRAN_ENV" _err_en_US);
73+ } else if (mustBeVariable && !IsVariable (*expr)) {
74+ context.Say (parser::FindSourceLocation (x),
75+ " Team must be a variable in this context" _err_en_US);
7276 }
7377 }
7478}
@@ -356,7 +360,15 @@ void CoarrayChecker::Leave(const parser::ImageSelector &imageSelector) {
356360}
357361
358362void CoarrayChecker::Leave (const parser::FormTeamStmt &x) {
359- CheckTeamType (context_, std::get<parser::TeamVariable>(x.t ));
363+ CheckTeamType (
364+ context_, std::get<parser::TeamVariable>(x.t ), /* mustBeVariable=*/ true );
365+ for (const auto &spec :
366+ std::get<std::list<parser::FormTeamStmt::FormTeamSpec>>(x.t )) {
367+ if (const auto *statOrErrmsg{std::get_if<parser::StatOrErrmsg>(&spec.u )}) {
368+ CheckCoindexedStatOrErrmsg (
369+ context_, *statOrErrmsg, " form-team-spec-list" );
370+ }
371+ }
360372}
361373
362374void CoarrayChecker::Enter (const parser::CriticalConstruct &x) {
0 commit comments