gcc/testsuite/gcc.dg/gomp/appendix-a/a.33.2.c
raw| 1 | /* { dg-do compile } */ |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | #include <stdlib.h> |
| 5 | float |
| 6 | read_next () |
| 7 | { |
| 8 | float *tmp; |
| 9 | float return_val; |
| 10 | #pragma omp single copyprivate(tmp) |
| 11 | { |
| 12 | tmp = (float *) malloc (sizeof (float)); |
| 13 | } /* copies the pointer only */ |
| 14 | #pragma omp master |
| 15 | { |
| 16 | scanf ("%f", tmp); |
| 17 | } |
| 18 | #pragma omp barrier |
| 19 | return_val = *tmp; |
| 20 | #pragma omp barrier |
| 21 | #pragma omp single nowait |
| 22 | { |
| 23 | free (tmp); |
| 24 | } |
| 25 | return return_val; |
| 26 | } |