PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/gcc/testsuite/gcc.dg/gomp/for-1.c

https://gitlab.com/sortix/gcc
C | 51 lines | 37 code | 10 blank | 4 comment | 10 complexity | 0c31307403d689d2602d6cfb4684ae73 MD5 | raw file
 1/* { dg-do compile } */
 2/* { dg-options "-fopenmp -fshow-column" } */
 3
 4void baz (int);
 5
 6void foo (int j, int k)
 7{
 8  int i;
 9
10  /* Valid loops.  */
11  #pragma omp for
12  for (i = 0; i < 10; i++)
13    baz (i);
14
15  #pragma omp for
16  for (i = j; i <= 10; i+=4)
17    baz (i);
18
19  #pragma omp for
20  for (i = j; i > 0; i = i - 1)
21    baz (j);
22
23  #pragma omp for
24  for (i = j; i >= k; i--)
25    baz (i);
26
27  /* Malformed parallel loops.  */
28  #pragma omp for
29  i = 0;		/* { dg-error "3:for statement expected" } */
30  for ( ; i < 10; )
31    {
32      baz (i);
33      i++;
34    }
35
36  #pragma omp for
37  for (i = 0; ; i--)	/* { dg-error "missing controlling predicate" } */
38    {
39      if (i >= 10)
40	break;		/* { dg-error "break" } */
41      baz (i);
42    }
43
44  #pragma omp for
45  for (i = 0; i < 10 && j > 4; i-=3)	/* { dg-error "15:invalid controlling predicate" } */
46    baz (i);
47
48  #pragma omp for
49  for (i = 0; i < 10; i-=3, j+=2)	/* { dg-error "27:invalid increment expression" } */
50    baz (i);
51}