aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/gomp/scan-6.c
blob: 0fdf66bf80d723642b12cbb220ce693254f14336 (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
void f1 (int, int, int);
int iii (int, int, int);

int
s1 (int a1, int a2, int a3)
{
  int r = 0;
  #pragma omp simd collapse(3) reduction (inscan, +:r)
  for (int i = 0; i < a1; i++)
    for (int j = 0; j < a2; j++)
      for (int k = 0; k < a3; k++)
	{
	  #pragma omp scan exclusive (r)  /* { dg-warning "'#pragma omp scan' with zero preceding executable statements" } */
	  f1 (2, k, r);
	}

  #pragma omp simd collapse(3) reduction (inscan, +:r)
  for (int i = 0; i < a1; i++)
    for (int j = 0; j < a2; j++)
      for (int k = 0; k < a3; k++)
	{
	  r += iii (i, j, k);
	  #pragma omp scan exclusive (r)  /* { dg-warning "'#pragma omp scan' with zero succeeding executable statements" } */
	}

  #pragma omp simd collapse(3) reduction (inscan, +:r)
  for (int i = 0; i < a1; i++)
    for (int j = 0; j < a2; j++)
      for (int k = 0; k < a3; k++)
	{
	  #pragma omp scan inclusive (r)
           /* { dg-warning "'#pragma omp scan' with zero preceding executable statements" "" { target *-*-* } .-1 } */
           /* { dg-warning "'#pragma omp scan' with zero succeeding executable statements" "" { target *-*-* } .-2 } */
	}
  return r;
}

int
s2 (int a1, int a2, int a3)
{
  int r = 0;
  #pragma omp simd collapse(3) reduction (inscan, +:r)  /* { dg-error "'r' specified in 'inscan' 'reduction' clause but not in 'scan' directive clause" } */
  for (int i = 0; i < a1; i++)
    for (int j = 0; j < a2; j++)
      for (int k = 0; k < a3; k++)
	{
	  f1 (2, k, r);
	  r += iii (i, j, k);  /* { dg-error "expected '#pragma omp scan'" "" { target c++ } } */
	}  /* { dg-error "expected '#pragma omp scan'" "" { target c } } */

  r = 0;
  #pragma omp simd collapse(3) reduction (inscan, +:r)  /* { dg-error "'r' specified in 'inscan' 'reduction' clause but not in 'scan' directive clause" } */
  for (int i = 0; i < a1; i++)
    for (int j = 0; j < a2; j++)
      for (int k = 0; k < a3; k++)
	;  /* { dg-error "expected '\{' before ';' token" } */

  #pragma omp simd collapse(3) reduction (inscan, +:r)  /* { dg-error "'r' specified in 'inscan' 'reduction' clause but not in 'scan' directive clause" } */
  for (int i = 0; i < a1; i++)
    for (int j = 0; j < a2; j++)
      for (int k = 0; k < a3; k++)
	{
	}  /* { dg-error "expected expression before '\}' token" "" { target c } } */
           /* { dg-error "expected primary-expression before '\}' token" "" { target c++ } .-1 } */
	   /* { dg-error "expected '#pragma omp scan'" "" { target *-*-* } .-2 } */


  r = 0;
  #pragma omp simd collapse(3) reduction (inscan, +:r)
  for (int i = 0; i < a1; i++)
    for (int j = 0; j < a2; j++)
      for (int k = 0; k < a3; k++)
	{
	  f1 (2, k, r);
	  #pragma omp scan inclusive (r)
	  #pragma omp scan inclusive (r)  /* { dg-error "'#pragma omp scan' may only be used in a loop construct with 'inscan' 'reduction' clause" } */
	  r += iii (i, j, k);
	}

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

  r = 0;
  #pragma omp simd collapse(3) reduction (inscan, +:r)  /* { dg-error "'r' specified in 'inscan' 'reduction' clause but not in 'scan' directive clause" } */
  for (int i = 0; i < a1; i++)
    for (int j = 0; j < a2; j++)
      for (int k = 0; k < a3; k++)
	{
	  f1 (2, k, r);
	  {
	    #pragma omp scan inclusive (r)  /* { dg-error "'#pragma omp scan' may only be used in a loop construct with 'inscan' 'reduction' clause" } */
	  }
	  r += iii (i, j, k);  /* { dg-error "expected '#pragma omp scan'" "" { target c++ } }  */
	}  /* { dg-error "expected '#pragma omp scan'" "" { target c } }  */
  return r;
}