aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/gomp/scan-1.c
blob: 95b46cbb71b8bd1ca6ddf4716724b9fcd2c06525 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
int a, b;

void
f1 (void)
{
  #pragma omp scan inclusive (a)	/* { dg-error "'#pragma omp scan' may only be used in a loop construct with 'inscan' 'reduction' clause" } */
  #pragma omp scan exclusive (b)	/* { dg-error "'#pragma omp scan' may only be used in a loop construct with 'inscan' 'reduction' clause" } */
}

void
f2 (int *c, int *d, int *e, int *f)
{
  int i, l = 1;
  #pragma omp for reduction (inscan, +: a) reduction (+: b)	/* { dg-error "'inscan' and non-'inscan' 'reduction' clauses on the same construct" } */
  for (i = 0; i < 64; i++)
    {
      { b++; a += c[i]; }
      #pragma omp scan inclusive (a)				/* { dg-error "" } */
      d[i] = a;
    }
  #pragma omp for reduction (+: a) reduction (inscan, +: b)	/* { dg-error "'inscan' and non-'inscan' 'reduction' clauses on the same construct" } */
  for (i = 0; i < 64; i++)
    {
      { a++; b += c[i]; }
      #pragma omp scan inclusive (b)				/* { dg-error "" } */
      d[i] = b;
    }
  #pragma omp for reduction (inscan, +: e[:2])			/* { dg-error "'inscan' 'reduction' clause with array section" } */
  for (i = 0; i < 64; ++i)
    {
      { e[0] += c[i]; e[1] += c[i]; }
      #pragma omp scan inclusive (a, e[:2])			/* { dg-error "" } */
      { d[i] = e[0]; f[i] = e[1]; }
    }
  #pragma omp for reduction (inscan, +: a) ordered		/* { dg-error "'ordered' clause specified together with 'inscan' 'reduction' clause" } */
  for (i = 0; i < 64; i++)
    {
      a += c[i];
      #pragma omp scan inclusive (a)				/* { dg-error "" } */
      d[i] = a;
    }
  #pragma omp for reduction (inscan, +: a) ordered(1)		/* { dg-error "'ordered' clause specified together with 'inscan' 'reduction' clause" } */
  for (i = 0; i < 64; i++)
    {
      a += c[i];
      #pragma omp scan inclusive (a)				/* { dg-error "" } */
      d[i] = a;
    }
  #pragma omp for reduction (inscan, +: a) schedule(static)	/* { dg-error "'schedule' clause specified together with 'inscan' 'reduction' clause" } */
  for (i = 0; i < 64; i++)
    {
      a += c[i];
      #pragma omp scan inclusive (a)				/* { dg-error "" } */
      d[i] = a;
    }
  #pragma omp for reduction (inscan, +: a) schedule(static, 2)	/* { dg-error "'schedule' clause specified together with 'inscan' 'reduction' clause" } */
  for (i = 0; i < 64; i++)
    {
      a += c[i];
      #pragma omp scan inclusive (a)				/* { dg-error "" } */
      d[i] = a;
    }
  #pragma omp for reduction (inscan, +: a) schedule(nonmonotonic: dynamic, 2)	/* { dg-error "'schedule' clause specified together with 'inscan' 'reduction' clause" } */
  for (i = 0; i < 64; i++)
    {
      a += c[i];
      #pragma omp scan inclusive (a)				/* { dg-error "" } */
      d[i] = a;
    }
  #pragma omp for reduction (inscan, +: a) linear (l)		/* { dg-error "'inscan' 'reduction' clause used together with 'linear' clause for a variable other than loop iterator" } */
  for (i = 0; i < 64; i++)
    {
      { a += c[i]; ++l; }
      #pragma omp scan inclusive (a)
      d[i] = a;
    }
}

void
f3 (int *c, int *d)
{
  int i;
  #pragma omp teams reduction (inscan, +: a)	/* { dg-error "'inscan' 'reduction' clause on 'teams' construct" } */
  ;
  #pragma omp parallel reduction (inscan, +: a)	/* { dg-error "'inscan' 'reduction' clause on 'parallel' construct" } */
  ;
  #pragma omp sections reduction (inscan, +: a)	/* { dg-error "'inscan' 'reduction' clause on 'sections' construct" } */
  {
    #pragma omp section
    ;
  }
  #pragma omp scope reduction (inscan, +: a)	/* { dg-error "'inscan' 'reduction' clause on 'scope' construct" } */
  ;
  #pragma omp target parallel for reduction (inscan, +: a) map (c[:64], d[:64])	/* { dg-error "'inscan' 'reduction' clause on construct other than 'for', 'simd', 'for simd', 'parallel for', 'parallel for simd'" } */
  for (i = 0; i < 64; i++)
    {
      d[i] = a;
      #pragma omp scan exclusive (a)	/* { dg-error "" } */
      a += c[i];
    }
  #pragma omp teams
  {
  #pragma omp distribute parallel for reduction (inscan, +: a)	/* { dg-error "'inscan' 'reduction' clause on construct other than 'for', 'simd', 'for simd', 'parallel for', 'parallel for simd'" } */
  for (i = 0; i < 64; i++)
    {
      d[i] = a;
      #pragma omp scan exclusive (a)	/* { dg-error "" } */
      a += c[i];
    }
  #pragma omp distribute parallel for simd reduction (inscan, +: a)	/* { dg-error "'inscan' 'reduction' clause on construct other than 'for', 'simd', 'for simd', 'parallel for', 'parallel for simd'" } */
  for (i = 0; i < 64; i++)
    {
      d[i] = a;
      #pragma omp scan exclusive (a)	/* { dg-error "" } */
      a += c[i];
    }
  }
}

void
f4 (int *c, int *d)
{
  int i;
  #pragma omp taskloop reduction (inscan, +: a)	/* { dg-error "'inscan' 'reduction' clause on 'taskloop' construct" } */
  for (i = 0; i < 64; i++)
    {
      d[i] = a;
      #pragma omp scan exclusive (a)	/* { dg-error "" } */
      a += c[i];
    }
}

void
f5 (int *c, int *d)
{
  int i;
  #pragma omp simd reduction (inscan, +: a)
  for (i = 0; i < 64; i++)
    {
      d[i] = a;
      #pragma omp scan exclusive (a, b)	/* { dg-error "'b' specified in 'exclusive' clause but not in 'inscan' 'reduction' clause on the containing construct" } */
      a += c[i];
    }
}

void
f6 (int *c, int *d)
{
  int i;
  #pragma omp simd reduction (inscan, +: a, b)	/* { dg-error "'b' specified in 'inscan' 'reduction' clause but not in 'scan' directive clause" } */
  for (i = 0; i < 64; i++)
    {
      d[i] = a;
      #pragma omp scan exclusive (a)
      a += c[i];
    }
}

void
f7 (void)
{
  int i;
  #pragma omp simd reduction (inscan, +: a)
  for (i = 0; i < 64; i++)
    {
      if (i == 23)	/* { dg-error "invalid exit from OpenMP structured block" "" { target c++ } .+1 } */
	continue;	/* { dg-error "invalid branch to/from OpenMP structured block" "" { target c } } */
      else if (i == 27)
	goto l1;	/* { dg-error "invalid branch to/from OpenMP structured block" } */
      #pragma omp scan exclusive (a)
      {
	l1: a = 0;	/* { dg-error "jump to label 'l1'" "" { target c++ } } */
	if (i == 33)	/* { dg-error "invalid exit from OpenMP structured block" "" { target c++ } .+1 } */
	  continue;	/* { dg-error "invalid branch to/from OpenMP structured block" "" { target c } } */
      }
  }
}

void
f8 (int *c, int *d, int *e, int *f)
{
  int i;
  #pragma omp for reduction (inscan, +: a, b)		/* { dg-error "'b' specified in 'inscan' 'reduction' clause but not in 'scan' directive clause" } */
  for (i = 0; i < 64; i++)
    {
      { a += c[i]; b += d[i]; }
      #pragma omp scan inclusive (a) inclusive (b)	/* { dg-error "expected end of line before 'inclusive'" } */
      { e[i] = a; f[i] = b; }
    }
  #pragma omp for reduction (inscan, +: a, b)		/* { dg-error "'.' specified in 'inscan' 'reduction' clause but not in 'scan' directive clause" } */
  for (i = 0; i < 64; i++)
    {
      { a += c[i]; b += d[i]; }
      #pragma omp scan					/* { dg-error "expected 'inclusive' or 'exclusive' clause before end of line" } */
      { e[i] = a; f[i] = b; }
    }
}

void
f9 (void)
{
  int i;
  #pragma omp simd reduction (inscan, +: a)
  for (i = 0; i < 64; i++)
    {
      if (i == 23)	/* { dg-error "invalid exit from OpenMP structured block" "" { target c++ } .+1 } */
	break;		/* { dg-error "break statement used with OpenMP for loop" "" { target c } } */
      #pragma omp scan exclusive (a)
      a++;
    }
}