xref: /llvm-project/clang/test/SemaOpenACC/compute-construct-wait-clause.cpp (revision 4bbdb018a6cb564783cfb9c65ca82b81c6006bb6)
1b1b46521Serichkeane // RUN: %clang_cc1 %s -fopenacc -verify
2b1b46521Serichkeane 
3b1b46521Serichkeane struct ExplicitConvertOnly {
4b1b46521Serichkeane   explicit operator int() const; // #EXPL_CONV
5b1b46521Serichkeane } Explicit;
6b1b46521Serichkeane 
7b1b46521Serichkeane struct AmbiguousConvert{
8b1b46521Serichkeane   operator int(); // #AMBIG_INT
9b1b46521Serichkeane   operator short(); // #AMBIG_SHORT
10b1b46521Serichkeane   operator float();
11b1b46521Serichkeane } Ambiguous;
12b1b46521Serichkeane 
13b1b46521Serichkeane void Test() {
14b1b46521Serichkeane 
15b1b46521Serichkeane   // expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}}
16b1b46521Serichkeane   // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
17b1b46521Serichkeane   // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
18b1b46521Serichkeane #pragma acc parallel wait(Ambiguous)
19b1b46521Serichkeane   while (true);
20b1b46521Serichkeane 
21*4bbdb018Serichkeane   // expected-error@+2{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' to 'int'}}
22b1b46521Serichkeane   // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
23b1b46521Serichkeane #pragma acc parallel wait(4, Explicit, 5)
24b1b46521Serichkeane   while (true);
25b1b46521Serichkeane 
26b1b46521Serichkeane   // expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}}
27b1b46521Serichkeane   // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
28b1b46521Serichkeane   // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
29b1b46521Serichkeane #pragma acc parallel wait(queues: Ambiguous, 5)
30b1b46521Serichkeane   while (true);
31b1b46521Serichkeane 
32*4bbdb018Serichkeane   // expected-error@+2{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' to 'int'}}
33b1b46521Serichkeane   // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
34b1b46521Serichkeane #pragma acc parallel wait(devnum: Explicit: 5)
35b1b46521Serichkeane   while (true);
36b1b46521Serichkeane 
37*4bbdb018Serichkeane   // expected-error@+2{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' to 'int'}}
38b1b46521Serichkeane   // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
39b1b46521Serichkeane #pragma acc parallel wait(devnum: Explicit:queues:  5)
40b1b46521Serichkeane   while (true);
41b1b46521Serichkeane 
42b1b46521Serichkeane   // expected-error@+1{{use of undeclared identifier 'queues'}}
43b1b46521Serichkeane #pragma acc parallel wait(devnum: queues:  5)
44b1b46521Serichkeane   while (true);
45b1b46521Serichkeane }
46b1b46521Serichkeane 
47b1b46521Serichkeane struct HasInt {
48b1b46521Serichkeane   using IntTy = int;
49b1b46521Serichkeane   using ShortTy = short;
50b1b46521Serichkeane   static constexpr int value = 1;
51b1b46521Serichkeane   static constexpr AmbiguousConvert ACValue;
52b1b46521Serichkeane   static constexpr ExplicitConvertOnly EXValue;
53b1b46521Serichkeane 
54b1b46521Serichkeane   operator char();
55b1b46521Serichkeane };
56b1b46521Serichkeane 
57b1b46521Serichkeane template<typename T>
58b1b46521Serichkeane void TestInst() {
59b1b46521Serichkeane 
60b1b46521Serichkeane #pragma acc parallel wait(T{})
61b1b46521Serichkeane   while (true);
62b1b46521Serichkeane 
63b1b46521Serichkeane #pragma acc parallel wait(devnum:typename T::ShortTy{}:queues:typename T::IntTy{})
64b1b46521Serichkeane   while (true);
65b1b46521Serichkeane 
66b1b46521Serichkeane   // expected-error@+4{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}}
67b1b46521Serichkeane   // expected-note@#INST{{in instantiation of function template specialization}}
68b1b46521Serichkeane   // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
69b1b46521Serichkeane   // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
70b1b46521Serichkeane #pragma acc parallel wait(devnum:T::value :queues:T::ACValue)
71b1b46521Serichkeane   while (true);
72b1b46521Serichkeane 
73*4bbdb018Serichkeane   // expected-error@+5{{OpenACC integer expression requires explicit conversion from 'const ExplicitConvertOnly' to 'int'}}
74b1b46521Serichkeane   // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
75b1b46521Serichkeane   // expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}}
76b1b46521Serichkeane   // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
77b1b46521Serichkeane   // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
78b1b46521Serichkeane #pragma acc parallel wait(devnum:T::EXValue :queues:T::ACValue)
79b1b46521Serichkeane   while (true);
80b1b46521Serichkeane 
81*4bbdb018Serichkeane   // expected-error@+5{{OpenACC integer expression requires explicit conversion from 'const ExplicitConvertOnly' to 'int'}}
82b1b46521Serichkeane   // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
83b1b46521Serichkeane   // expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}}
84b1b46521Serichkeane   // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
85b1b46521Serichkeane   // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
86b1b46521Serichkeane #pragma acc parallel wait(T::EXValue, T::ACValue)
87b1b46521Serichkeane   while (true);
88b1b46521Serichkeane 
89*4bbdb018Serichkeane   // expected-error@+5{{OpenACC integer expression requires explicit conversion from 'const ExplicitConvertOnly' to 'int'}}
90b1b46521Serichkeane   // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
91b1b46521Serichkeane   // expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}}
92b1b46521Serichkeane   // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
93b1b46521Serichkeane   // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
94b1b46521Serichkeane #pragma acc parallel wait(queues: T::EXValue, T::ACValue)
95b1b46521Serichkeane   while (true);
96b1b46521Serichkeane 
97b1b46521Serichkeane   // expected-error@+1{{no member named 'Invalid' in 'HasInt'}}
98b1b46521Serichkeane #pragma acc parallel wait(queues: T::Invalid, T::Invalid2)
99b1b46521Serichkeane   while (true);
100b1b46521Serichkeane }
101b1b46521Serichkeane 
102b1b46521Serichkeane void Inst() {
103b1b46521Serichkeane   TestInst<HasInt>(); // #INST
104b1b46521Serichkeane }
105