summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/gomp/for-11.c
blob: 8c747cdb981d616aa6fb70e5b48a81edb0abb3b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* { dg-do compile } */
/* { dg-options "-std=c99 -fopenmp" } */

extern void baz (int);

void foo (int j, int k)
{
  int i;

  /* Valid loops.  */
  #pragma omp for
  for (i = 0; i < 10; i++)
    baz (i);

  #pragma omp for
  for (i = j; i <= 10; i+=4)
    baz (i);

  #pragma omp for
  for (i = j; i > 0; i = i - 1)
    baz (j);

  #pragma omp for
  for (i = j; i >= k; i--)
    baz (i);

  #pragma omp for
  for (int l = j; l < 10; l++)
    baz (l);

  /* Malformed parallel loops.  */
  #pragma omp for
  i = 0;		/* { dg-error "for statement expected" } */
  for ( ; i < 10; )
    {
      baz (i);
      i++;
    }

  #pragma omp for
  for (i = 0; ; i--)	/* { dg-error "missing controlling predicate" } */
    {
      if (i >= 10)
	break;		/* { dg-error "break" } */
      baz (i);
    }

  #pragma omp for
  for (i = 0;
       i < 10 && j > 4; /* { dg-error "invalid controlling predicate" } */
       i-=3)
    baz (i);

  #pragma omp for
  for (i = 0;
       i < 10;
       i-=3, j+=2)	/* { dg-error "invalid increment expression" } */
    baz (i);

  int m = 0;
  #pragma omp for
  for (; m < 10; m++)	/* { dg-error "expected" } */
    baz (m);

  m = 0;
  #pragma omp for
  for (int n = 0; m < 10; m++)	/* { dg-error "invalid controlling predicate|invalid increment expression" } */
    baz (m);

  #pragma omp for
  for (m = 0; m < 10; i++)	/* { dg-error "invalid increment expression" } */
    baz (m);
}