[flang-commits] [flang] [llvm] [flang][OpenMP] Check that IF clause applies to at most one leaf (PR #205164)
via flang-commits
flang-commits at lists.llvm.org
Tue Jun 23 13:00:32 PDT 2026
================
@@ -4334,39 +4345,90 @@ void OmpStructureChecker::Enter(const parser::OmpClause::If &x) {
std::string modName{desc.name.str()};
if (!isConstituent(dir, sub)) {
- context_
- .Say(modifierSource,
- "%s is not a constituent of the %s directive"_err_en_US, subName,
- dirName)
- .Attach(
- GetContext().directiveSource, "Cannot apply to directive"_en_US);
+ context_.Say(modifierSource,
+ "%s is not a constituent of the %s directive"_err_en_US, subName,
+ dirName);
} else {
- static llvm::omp::Directive valid45[]{
- llvm::omp::OMPD_cancel, //
- llvm::omp::OMPD_parallel, //
- /* OMP 5.0+ also allows OMPD_simd */
- llvm::omp::OMPD_target, //
- llvm::omp::OMPD_target_data, //
- llvm::omp::OMPD_target_enter_data, //
- llvm::omp::OMPD_target_exit_data, //
- llvm::omp::OMPD_target_update, //
- llvm::omp::OMPD_task, //
- llvm::omp::OMPD_taskloop, //
- /* OMP 5.2+ also allows OMPD_teams */
+ static OmpDirectiveSet valid45{
+ llvm::omp::Directive::OMPD_cancel, //
+ llvm::omp::Directive::OMPD_parallel, //
+ llvm::omp::Directive::OMPD_target, //
+ llvm::omp::Directive::OMPD_target_data, //
+ llvm::omp::Directive::OMPD_target_enter_data, //
+ llvm::omp::Directive::OMPD_target_exit_data, //
+ llvm::omp::Directive::OMPD_target_update, //
+ llvm::omp::Directive::OMPD_task, //
+ llvm::omp::Directive::OMPD_taskloop, //
};
- if (version < 50 && sub == llvm::omp::OMPD_simd) {
+ static OmpDirectiveSet valid50{
+ valid45 | OmpDirectiveSet{llvm::omp::Directive::OMPD_simd}};
+ static OmpDirectiveSet valid52{
+ valid50 | OmpDirectiveSet{llvm::omp::Directive::OMPD_teams}};
+ static OmpDirectiveSet valid60{valid52 |
+ OmpDirectiveSet{llvm::omp::Directive::OMPD_taskgraph,
+ /*TODO llvm::omp::Directive::OMPD_task_iteration*/}};
+
+ static auto minVersion{[&](llvm::omp::Directive d) {
----------------
kwyatt-ext wrote:
This lambda as static captures locals, also static. This isn't a problem, but if changes are made this could cause a bug down the road. Non-static would be preferrable, but I'll leave this as your call.
https://github.com/llvm/llvm-project/pull/205164
More information about the flang-commits
mailing list