1 // RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run
2 // Clang had a bug until version 4.0.1 which resulted in a hang.
3 // UNSUPPORTED: clang-3, clang-4.0.0
5 // Regression test for a bug in cancellation to cover effect of `#pragma omp cancel`
6 // in a loop construct, on sections construct.
7 // Pass condition: Cancellation status from `for` does not persist
13 int result
[2] = {0, 0};
15 void cq416850_for_sections() {
20 for (i
= 0; i
< 1; i
++) {
22 #pragma omp cancel for
26 // printf("thread %d: result[0] = %d, result[1] = %d \n", omp_get_thread_num(), result[0], result[1]);
35 #pragma omp cancellation point sections
42 if(!omp_get_cancellation()) {
43 printf("Cancellation not enabled!\n");
47 #pragma omp parallel num_threads(4)
49 cq416850_for_sections();
52 if (result
[0] != 1 || result
[1] != 2) {
53 printf("Incorrect values. "
54 "result[0] = %d (expected 1), "
55 "result[1] = %d (expected 2).\n",
56 result
[0], result
[1]);