Open llvmbot opened 4 years ago
I tend to disagree with this. According to the standard, "closely nested construct" is "A construct nested inside another construct with no other construct nested between them." and "nested construct" is "A construct (lexically) enclosed by another construct.". The basic word here is "lexically". In the second example, the construct lexically is not enclosed into the first worksharing construct.
Add test information:
clang version 10.0.0 Target: x86_64-unknown-linux-gnu Thread model: posix
Extended Description
According to OpenMP5.0's Restriction:
2.20 Nesting of Regions A worksharing region may not be closely nested inside a worksharing, loop, task, taskloop, critical, ordered, atomic, or master region. https://www.openmp.org/spec-html/5.0/openmpse28.html#x143-6330002.20
closely nested construct: A construct nested inside another construct with no other construct nested between them. https://www.openmp.org/spec-html/5.0/openmpsu2.html#x9-80001.2.2
The following examples are non-conforming because the inner and outer loop regions are closely nested,clang should report an error for case nesting_restrict.2.c as nesting_restrict.1.c.
These testcases are from: https://www.openmp.org/wp-content/uploads/openmp-examples-5.0.0.pdf p378
nesting_restrict.1.c
void work(int i, int j) {}
void wrong1(int n) {
pragma omp parallel default(shared)
{ int i, j;
pragma omp for
} }
clang -fopenmp-version=50 -fopenmp -S Example_nesting_restrict.1.c
Example_nesting_restrict.1.c:20:8: error: region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?
pragma omp for
1 error generated.
nesting_restrict.2.c
void work(int i, int j) {} void work1(int i, int n) { int j; / incorrect nesting of loop regions /
pragma omp for
}
void wrong2(int n) {
pragma omp parallel default(shared)
{ int i;
pragma omp for
} }
clang -fopenmp-version=50 -fopenmp -S Example_nesting_restrict.2.c