@@ -5363,6 +5363,82 @@ void OmpStructureChecker::Enter(const parser::OmpClause::SelfMaps &x) {
53635363 CheckAllowedRequiresClause (llvm::omp::Clause::OMPC_self_maps);
53645364}
53655365
5366+ void OmpStructureChecker::CheckDimsModifier (parser::CharBlock source,
5367+ size_t numValues, const parser::OmpDimsModifier &x) {
5368+ std::string name{OmpGetDescriptor<parser::OmpDimsModifier>().name .str ()};
5369+
5370+ if (auto dimsVal{GetIntValue (x.v )}) {
5371+ if (*dimsVal > 0 ) {
5372+ if (static_cast <size_t >(*dimsVal) < numValues) {
5373+ context_.Say (source,
5374+ " The %s specifies %d dimensions but %zu values were provided" _err_en_US,
5375+ name, *dimsVal, numValues);
5376+ }
5377+ } else {
5378+ context_.Say (
5379+ source, " The argument to the %s should be positive" _err_en_US, name);
5380+ }
5381+ }
5382+ // The non-constant expression case is diagnosed elsewhere.
5383+ }
5384+
5385+ void OmpStructureChecker::Enter (const parser::OmpClause::NumTeams &x) {
5386+ constexpr auto clauseId{llvm::omp::Clause::OMPC_num_teams};
5387+ CheckAllowedClause (clauseId);
5388+ parser::CharBlock source{GetContext ().clauseSource };
5389+ auto &values{std::get<std::list<parser::ScalarIntExpr>>(x.v .t )};
5390+
5391+ if (OmpVerifyModifiers (x.v , clauseId, source, context_)) {
5392+ auto &modifiers{OmpGetModifiers (x.v )};
5393+ if (auto *dims{OmpGetUniqueModifier<parser::OmpDimsModifier>(modifiers)}) {
5394+ CheckDimsModifier (
5395+ OmpGetModifierSource (modifiers, dims), values.size (), *dims);
5396+ }
5397+ }
5398+
5399+ for (auto &val : values) {
5400+ RequiresPositiveParameter (clauseId, val);
5401+ }
5402+ }
5403+
5404+ void OmpStructureChecker::Enter (const parser::OmpClause::NumThreads &x) {
5405+ constexpr auto clauseId{llvm::omp::Clause::OMPC_num_threads};
5406+ CheckAllowedClause (clauseId);
5407+ parser::CharBlock source{GetContext ().clauseSource };
5408+ auto &values{std::get<std::list<parser::ScalarIntExpr>>(x.v .t )};
5409+
5410+ if (OmpVerifyModifiers (x.v , clauseId, source, context_)) {
5411+ auto &modifiers{OmpGetModifiers (x.v )};
5412+ if (auto *dims{OmpGetUniqueModifier<parser::OmpDimsModifier>(modifiers)}) {
5413+ CheckDimsModifier (
5414+ OmpGetModifierSource (modifiers, dims), values.size (), *dims);
5415+ }
5416+ }
5417+
5418+ for (auto &val : values) {
5419+ RequiresPositiveParameter (clauseId, val);
5420+ }
5421+ }
5422+
5423+ void OmpStructureChecker::Enter (const parser::OmpClause::ThreadLimit &x) {
5424+ constexpr auto clauseId{llvm::omp::Clause::OMPC_thread_limit};
5425+ CheckAllowedClause (clauseId);
5426+ parser::CharBlock source{GetContext ().clauseSource };
5427+ auto &values{std::get<std::list<parser::ScalarIntExpr>>(x.v .t )};
5428+
5429+ if (OmpVerifyModifiers (x.v , clauseId, source, context_)) {
5430+ auto &modifiers{OmpGetModifiers (x.v )};
5431+ if (auto *dims{OmpGetUniqueModifier<parser::OmpDimsModifier>(modifiers)}) {
5432+ CheckDimsModifier (
5433+ OmpGetModifierSource (modifiers, dims), values.size (), *dims);
5434+ }
5435+ }
5436+
5437+ for (auto &val : values) {
5438+ RequiresPositiveParameter (clauseId, val);
5439+ }
5440+ }
5441+
53665442void OmpStructureChecker::Enter (const parser::OpenMPInteropConstruct &x) {
53675443 bool isDependClauseOccured{false };
53685444 int targetCount{0 }, targetSyncCount{0 };
@@ -5569,11 +5645,8 @@ CHECK_SIMPLE_CLAUSE(UsesAllocators, OMPC_uses_allocators)
55695645CHECK_SIMPLE_CLAUSE (Weak, OMPC_weak)
55705646CHECK_SIMPLE_CLAUSE (Write, OMPC_write)
55715647
5572- CHECK_REQ_SCALAR_INT_CLAUSE (NumTeams, OMPC_num_teams)
5573- CHECK_REQ_SCALAR_INT_CLAUSE (NumThreads, OMPC_num_threads)
55745648CHECK_REQ_SCALAR_INT_CLAUSE (OmpxDynCgroupMem, OMPC_ompx_dyn_cgroup_mem)
55755649CHECK_REQ_SCALAR_INT_CLAUSE (Priority, OMPC_priority)
5576- CHECK_REQ_SCALAR_INT_CLAUSE (ThreadLimit, OMPC_thread_limit)
55775650
55785651CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE (Collapse, OMPC_collapse)
55795652CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE (Safelen, OMPC_safelen)
0 commit comments