aboutsummaryrefslogtreecommitdiff
path: root/clang/test/SemaOpenACC/update-construct.cpp
blob: 2abd7a30eda888193f82370a136699985b4ac203 (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
// RUN: %clang_cc1 %s -fopenacc -verify

struct NotConvertible{} NC;
int getI();
void uses() {
  int Var;
#pragma acc update async self(Var)
#pragma acc update wait self(Var)
#pragma acc update self(Var) device_type(I)
#pragma acc update if(true) self(Var)
#pragma acc update if_present self(Var)
#pragma acc update self(Var)
  // expected-warning@+1{{OpenACC clause 'host' not yet implemented}}
#pragma acc update host(Var)
  // expected-warning@+1{{OpenACC clause 'device' not yet implemented}}
#pragma acc update device(Var)

  // expected-error@+2{{OpenACC clause 'if' may not follow a 'device_type' clause in a 'update' construct}}
  // expected-note@+1{{previous clause is here}}
#pragma acc update self(Var) device_type(I) if(true)
  // expected-error@+2{{OpenACC clause 'if_present' may not follow a 'device_type' clause in a 'update' construct}}
  // expected-note@+1{{previous clause is here}}
#pragma acc update self(Var) device_type(I) if_present
  // expected-error@+2{{OpenACC clause 'self' may not follow a 'device_type' clause in a 'update' construct}}
  // expected-note@+1{{previous clause is here}}
#pragma acc update device_type(I) self(Var)
  // expected-error@+2{{OpenACC clause 'host' may not follow a 'device_type' clause in a 'update' construct}}
  // expected-note@+1{{previous clause is here}}
#pragma acc update device_type(I) host(Var)
  // expected-error@+2{{OpenACC clause 'device' may not follow a 'device_type' clause in a 'update' construct}}
  // expected-note@+1{{previous clause is here}}
#pragma acc update device_type(I) device(Var)
  // These 2 are OK.
#pragma acc update self(Var) device_type(I) async
#pragma acc update self(Var) device_type(I) wait
  // Unless otherwise specified, we assume 'device_type' can happen after itself.
#pragma acc update self(Var) device_type(I) device_type(I)

  // TODO: OpenACC: These should diagnose because there isn't at least 1 of
  // 'self', 'host', or 'device'.
#pragma acc update async
#pragma acc update wait
#pragma acc update device_type(I)
#pragma acc update if(true)
#pragma acc update if_present

  // expected-error@+1{{value of type 'struct NotConvertible' is not contextually convertible to 'bool'}}
#pragma acc update if (NC) device_type(I)

  // expected-error@+2{{OpenACC 'if' clause cannot appear more than once on a 'update' directive}}
  // expected-note@+1{{previous clause is here}}
#pragma acc update if(true) if (false)

  // TODO: OpenACC: There is restrictions on the contents of a 'varlist', so
  // those should be checked here too.

  // Cannot be the body of an 'if', 'while', 'do', 'switch', or
  // 'label'.
  // expected-error@+3{{OpenACC 'update' construct may not appear in place of the statement following an if statement}}
  if (true)
    // expected-warning@+1{{OpenACC clause 'device' not yet implemented}}
#pragma acc update device(Var)

  // expected-error@+3{{OpenACC 'update' construct may not appear in place of the statement following a while statement}}
  while (true)
    // expected-warning@+1{{OpenACC clause 'device' not yet implemented}}
#pragma acc update device(Var)

  // expected-error@+3{{OpenACC 'update' construct may not appear in place of the statement following a do statement}}
  do
    // expected-warning@+1{{OpenACC clause 'device' not yet implemented}}
#pragma acc update device(Var)
  while (true);

  // expected-error@+3{{OpenACC 'update' construct may not appear in place of the statement following a switch statement}}
  switch(Var)
    // expected-warning@+1{{OpenACC clause 'device' not yet implemented}}
#pragma acc update device(Var)

  // expected-error@+3{{OpenACC 'update' construct may not appear in place of the statement following a label statement}}
  LABEL:
    // expected-warning@+1{{OpenACC clause 'device' not yet implemented}}
#pragma acc update device(Var)

  // For loops are OK.
  for (;;)
    // expected-warning@+1{{OpenACC clause 'device' not yet implemented}}
#pragma acc update device(Var)

  // Checking for 'async', which requires an 'int' expression.
#pragma acc update async

#pragma acc update async(getI())
  // expected-error@+2{{expected ')'}}
  // expected-note@+1{{to match this '('}}
#pragma acc update async(getI(), getI())
  // expected-error@+2{{OpenACC 'async' clause cannot appear more than once on a 'update' directive}}
  // expected-note@+1{{previous clause is here}}
#pragma acc update async(getI()) async(getI())
  // expected-error@+1{{OpenACC clause 'async' requires expression of integer type ('struct NotConvertible' invalid)}}
#pragma acc update async(NC)

  // Checking for 'wait', which has a complicated set arguments.
#pragma acc update wait
#pragma acc update wait()
#pragma acc update wait(getI(), getI())
#pragma acc update wait(devnum: getI():  getI())
#pragma acc update wait(devnum: getI(): queues: getI(), getI())
  // expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}}
#pragma acc update wait(devnum:NC : 5)
  // expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}}
#pragma acc update wait(devnum:5 : NC)

    int arr[5];
  // expected-error@+3{{OpenACC clause 'wait' requires expression of integer type ('int[5]' invalid)}}
  // expected-error@+2{{OpenACC clause 'wait' requires expression of integer type ('int[5]' invalid)}}
  // expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}}
#pragma acc update wait(devnum:arr : queues: arr, NC, 5)
}

struct SomeS {
  int Array[5];
  int MemberOfComp;
};

template<typename I, typename T>
void varlist_restrictions_templ() {
  I iArray[5];
  T Single;
  T Array[5];

  // Members of a subarray of struct or class type may not appear, but others
  // are permitted to.
#pragma acc update self(iArray[0:1])

#pragma acc update self(Array[0:1])

  // expected-error@+1{{OpenACC sub-array is not allowed here}}
#pragma acc update self(Array[0:1].MemberOfComp)
}

void varlist_restrictions() {
  varlist_restrictions_templ<int, SomeS>();// expected-note{{in instantiation of}}
  int iArray[5];
  SomeS Single;
  SomeS Array[5];

  int LocalInt;
  int *LocalPtr;

#pragma acc update self(LocalInt, LocalPtr, Single)

#pragma acc update self(Single.MemberOfComp)

#pragma acc update self(Single.Array[0:1])


  // Members of a subarray of struct or class type may not appear, but others
  // are permitted to.
#pragma acc update self(iArray[0:1])

#pragma acc update self(Array[0:1])

  // expected-error@+1{{OpenACC sub-array is not allowed here}}
#pragma acc update self(Array[0:1].MemberOfComp)
}