Debian Codegraph @

clang/test/SemaOpenACC/combined-construct-wait-clause.cpp

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