[flang] [llvm] [Frontend][OpenMP] Follow compound construct clause restrictions (PR #107853)

Sergio Afonso via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 02:46:01 PDT 2024


skatrak wrote:

> In OMP.td the clauses on compound constructs should be unions of clauses from the leaf constructs. This is the default assumption in the spec. Special case restrictions, like the ones from 17.4 should be handled in separate checks.

Did you have a particular suggestion in mind? I can think of perhaps updating the `GenerateIsAllowedClause` tablegen method to detect these edge cases based on the name of the directive and clause, but I don't think that's a good solution at all. Otherwise, it seems to me that your suggestion would have to be implemented as semantic checks for both clang and flang, which I don't think is better than what I proposed here.

I guess I don't quite get what the problem is with embedding these restrictions as part of the list of `allowedClauses` of compound constructs. I get it for dynamic restrictions based on what other clauses are present, what parent constructs there are and so on. But, for example, `copyin` is never accepted as a clause to a `target` compound construct, so it shouldn't be in the list of `allowedClauses` even if it would be applicable to some of its leaf constructs. In fact, before this PR, for example `OMP_TargetParallelFor` already did not include `OMPC_Copyin` (and most of the changes here are to fortran-only constructs that include these clauses clang-only variants do not).

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


More information about the llvm-commits mailing list