[flang][OpenMP] Add semantic checks for cancellation nesting
authorPeixin Qiao <qiaopeixin@huawei.com>
Fri, 13 Aug 2021 12:19:01 +0000 (08:19 -0400)
committerArnamoy Bhattacharyya <arnamoy.bhattacharyya@huawei.com>
Fri, 13 Aug 2021 14:11:39 +0000 (10:11 -0400)
commit70894c8dd14d35ba8bc6ab317d76e0b325c3f7f0
tree4ff5feaebe9f2dd96cab7beb85407c510c58b4db
parentd754b970eddb83b1c68346a36b067391d93166b0
[flang][OpenMP] Add semantic checks for cancellation nesting

This patch implements the following semantic checks for cancellation constructs:
```
OpenMP Version 5.0 Section 2.18.1: CANCEL construct restriction:
If construct-type-clause is taskgroup, the cancel construct must be
closely nested inside a task or a taskloop construct and the cancel
region must be closely nested inside a taskgroup region. If
construct-type-clause is sections, the cancel construct must be closely
nested inside a sections or section construct. Otherwise, the cancel
construct must be closely nested inside an OpenMP construct that matches
the type specified in construct-type-clause of the cancel construct.

OpenMP Version 5.0 Section 2.18.2: CANCELLATION POINT restriction:
A cancellation point construct for which construct-type-clause is
taskgroup must be closely nested inside a task or taskloop construct,
and the cancellation point region must be closely nested inside a
taskgroup region. A cancellation point construct for which
construct-type-clause is sections must be closely nested inside a
sections or section construct. A cancellation point construct for which
construct-type-clause is neither sections nor taskgroup must be closely
nested inside an OpenMP construct that matches the type specified in
construct-type-clause.
```

Also add test cases for the check.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D106538
flang/lib/Semantics/check-omp-structure.cpp
flang/lib/Semantics/check-omp-structure.h
flang/test/Semantics/omp-clause-validity01.f90
flang/test/Semantics/omp-nested-cancel.f90 [new file with mode: 0644]
flang/test/Semantics/omp-nested-cancellation-point.f90 [new file with mode: 0644]