@@ -97,11 +97,15 @@ class ChangeTeamBodyEnforce {
9797};
9898
9999template <typename T>
100- static void CheckTeamType (SemanticsContext &context, const T &x) {
100+ static void CheckTeamType (
101+ SemanticsContext &context, const T &x, bool mustBeVariable = false ) {
101102 if (const auto *expr{GetExpr (context, x)}) {
102103 if (!IsTeamType (evaluate::GetDerivedTypeSpec (expr->GetType ()))) {
103104 context.Say (parser::FindSourceLocation (x), // C1114
104105 " Team value must be of type TEAM_TYPE from module ISO_FORTRAN_ENV" _err_en_US);
106+ } else if (mustBeVariable && !IsVariable (*expr)) {
107+ context.Say (parser::FindSourceLocation (x),
108+ " Team must be a variable in this context" _err_en_US);
105109 }
106110 }
107111}
@@ -389,7 +393,15 @@ void CoarrayChecker::Leave(const parser::ImageSelector &imageSelector) {
389393}
390394
391395void CoarrayChecker::Leave (const parser::FormTeamStmt &x) {
392- CheckTeamType (context_, std::get<parser::TeamVariable>(x.t ));
396+ CheckTeamType (
397+ context_, std::get<parser::TeamVariable>(x.t ), /* mustBeVariable=*/ true );
398+ for (const auto &spec :
399+ std::get<std::list<parser::FormTeamStmt::FormTeamSpec>>(x.t )) {
400+ if (const auto *statOrErrmsg{std::get_if<parser::StatOrErrmsg>(&spec.u )}) {
401+ CheckCoindexedStatOrErrmsg (
402+ context_, *statOrErrmsg, " form-team-spec-list" );
403+ }
404+ }
393405}
394406
395407void CoarrayChecker::Enter (const parser::CriticalConstruct &x) {
0 commit comments