1// RUN: %libomp-compile-and-run
2#include <stdio.h>
3#include "omp_testsuite.h"
4
5int test_omp_parallel_sections_firstprivate()
6{
7 int sum;
8 int sum0;
9 int known_sum;
10
11 sum =7;
12 sum0=11;
13
14 #pragma omp parallel sections firstprivate(sum0)
15 {
16 #pragma omp section
17 {
18 #pragma omp critical
19 {
20 sum= sum+sum0;
21 }
22 }
23 #pragma omp section
24 {
25 #pragma omp critical
26 {
27 sum= sum+sum0;
28 }
29 }
30 #pragma omp section
31 {
32 #pragma omp critical
33 {
34 sum= sum+sum0;
35 }
36 }
37 }
38
39 known_sum=11*3+7;
40 return (known_sum==sum);
41} /* end of check_section_firstprivate*/
42
43int main()
44{
45 int i;
46 int num_failed=0;
47
48 for(i = 0; i < REPETITIONS; i++) {
49 if(!test_omp_parallel_sections_firstprivate()) {
50 num_failed++;
51 }
52 }
53 return num_failed;
54}
55

source code of openmp/runtime/test/worksharing/sections/omp_parallel_sections_firstprivate.c