Merge from mainline
[official-gcc.git] / libgomp / testsuite / libgomp.c / omp_workshare3.c
blob913f1f731bf8ef849655138d708cd840e42b9a14
1 /* { dg-do compile } */
3 /******************************************************************************
4 * OpenMP Example - Combined Parallel Loop Work-sharing - C/C++ Version
5 * FILE: omp_workshare3.c
6 * DESCRIPTION:
7 * This example attempts to show use of the parallel for construct. However
8 * it will generate errors at compile time. Try to determine what is causing
9 * the error. See omp_workshare4.c for a corrected version.
10 * SOURCE: Blaise Barney 5/99
11 * LAST REVISED: 03/03/2002
12 ******************************************************************************/
14 #include <omp.h>
15 #include <stdio.h>
16 #define N 50
17 #define CHUNKSIZE 5
19 main () {
21 int i, chunk, tid;
22 float a[N], b[N], c[N];
24 /* Some initializations */
25 for (i=0; i < N; i++)
26 a[i] = b[i] = i * 1.0;
27 chunk = CHUNKSIZE;
29 #pragma omp parallel for \
30 shared(a,b,c,chunk) \
31 private(i,tid) \
32 schedule(static,chunk)
33 { /* { dg-error "expected" } */
34 tid = omp_get_thread_num();
35 for (i=0; i < N; i++)
37 c[i] = a[i] + b[i];
38 printf("tid= %d i= %d c[i]= %f\n", tid, i, c[i]);
40 } /* end of parallel for construct */
42 return 0;