1// RUN: %libomp-compile-and-run
2
3// Support for collapse of non-rectangular loop nests was added in GCC 11
4// UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7, gcc-8, gcc-9, gcc-10
5
6#include <stdio.h>
7
8#define N 3
9
10int arr[N][N][N];
11int main() {
12#pragma omp for collapse(3)
13 for (unsigned int i = 0; i < N; ++i)
14 for (unsigned int j = i; j < N; ++j)
15 for (unsigned int k = j; k < N; ++k)
16 arr[i][j][k] = 1;
17 int num_failed = 0;
18 for (unsigned int i = 0; i < N; ++i)
19 for (unsigned int j = 0; j < N; ++j)
20 for (unsigned int k = 0; k < N; ++k)
21 if (arr[i][j][k] == (j >= i && k >= j) ? 0 : 1)
22 ++num_failed;
23
24 return num_failed;
25}
26

source code of openmp/runtime/test/worksharing/for/omp_for_collapse_non_rectangular.c