[RISCV][VLOPT] Add vector narrowing integer right shift instructions to isSupportedIn...
[llvm-project.git] / openmp / runtime / test / misc_bugs / cancellation_for_sections.c
blob7cdaa1f3c5c3b048e26ef5081412eee5cf46835a
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
8 // to `sections`.
10 #include <stdio.h>
11 #include <omp.h>
13 int result[2] = {0, 0};
15 void cq416850_for_sections() {
17 unsigned i;
18 // 1) loop
19 #pragma omp for
20 for (i = 0; i < 1; i++) {
21 result[0] = 1;
22 #pragma omp cancel for
23 result[0] = 2;
26 // printf("thread %d: result[0] = %d, result[1] = %d \n", omp_get_thread_num(), result[0], result[1]);
29 // 2) sections
30 #pragma omp sections
32 #pragma omp section
34 result[1] = 1;
35 #pragma omp cancellation point sections
36 result[1] = 2;
41 int main(void) {
42 if(!omp_get_cancellation()) {
43 printf("Cancellation not enabled!\n");
44 return 2;
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]);
57 printf("FAILED\n");
58 return 1;
61 printf("PASSED\n");
62 return 0;