Debian Codegraph @

clang/test/SemaOpenACC/compute-construct-async-clause.cpp

raw
1 // RUN: %clang_cc1 %s -fopenacc -verify
2
3 struct NotConvertible{} NC;
4 struct Incomplete *SomeIncomplete; // #INCOMPLETE
5 enum E{} SomeE;
6 enum class E2{} SomeE2;
7
8 struct CorrectConvert {
9 operator int();
10 } Convert;
11
12 struct ExplicitConvertOnly {
13 explicit operator int() const; // #EXPL_CONV
14 } Explicit;
15
16 struct AmbiguousConvert{
17 operator int(); // #AMBIG_INT
18 operator short(); // #AMBIG_SHORT
19 operator float();
20 } Ambiguous;
21
22 void Test() {
23 #pragma acc parallel async
24 while(1);
25 #pragma acc parallel async(1)
26 while(1);
27 #pragma acc kernels async(-51)
28 while(1);
29
30 // expected-error@+1{{OpenACC clause 'async' requires expression of integer type ('struct NotConvertible' invalid}}
31 #pragma acc parallel async(NC)
32 while(1);
33
34 // expected-error@+2{{OpenACC integer expression has incomplete class type 'struct Incomplete'}}
35 // expected-note@#INCOMPLETE{{forward declaration of 'Incomplete'}}
36 #pragma acc kernels async(*SomeIncomplete)
37 while(1);
38
39 #pragma acc parallel async(SomeE)
40 while(1);
41
42 // expected-error@+1{{OpenACC clause 'async' requires expression of integer type ('enum E2' invalid}}
43 #pragma acc kernels async(SomeE2)
44 while(1);
45
46 #pragma acc parallel async(Convert)
47 while(1);
48
49 // expected-error@+2{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' to 'int'}}
50 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
51 #pragma acc kernels async(Explicit)
52 while(1);
53
54 // expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}}
55 // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
56 // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
57 #pragma acc parallel async(Ambiguous)
58 while(1);
59 }
60
61 struct HasInt {
62 using IntTy = int;
63 using ShortTy = short;
64 static constexpr int value = 1;
65 static constexpr AmbiguousConvert ACValue;
66 static constexpr ExplicitConvertOnly EXValue;
67
68 operator char();
69 };
70
71 template<typename T>
72 void TestInst() {
73
74 // expected-error@+1{{no member named 'Invalid' in 'HasInt'}}
75 #pragma acc parallel async(HasInt::Invalid)
76 while (1);
77
78 // expected-error@+2{{no member named 'Invalid' in 'HasInt'}}
79 // expected-note@#INST{{in instantiation of function template specialization 'TestInst<HasInt>' requested here}}
80 #pragma acc kernels async(T::Invalid)
81 while (1);
82
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 async(HasInt::ACValue)
87 while (1);
88
89 // expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}}
90 // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
91 // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
92 #pragma acc kernels async(T::ACValue)
93 while (1);
94
95 // expected-error@+2{{OpenACC integer expression requires explicit conversion from 'const ExplicitConvertOnly' to 'int'}}
96 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
97 #pragma acc parallel async(HasInt::EXValue)
98 while (1);
99
100 // expected-error@+2{{OpenACC integer expression requires explicit conversion from 'const ExplicitConvertOnly' to 'int'}}
101 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
102 #pragma acc kernels async(T::EXValue)
103 while (1);
104
105 #pragma acc parallel async(HasInt::value)
106 while (1);
107
108 #pragma acc kernels async(T::value)
109 while (1);
110
111 #pragma acc parallel async(HasInt::IntTy{})
112 while (1);
113
114 #pragma acc kernels async(typename T::ShortTy{})
115 while (1);
116
117 #pragma acc parallel async(HasInt::IntTy{})
118 while (1);
119
120 #pragma acc kernels async(typename T::ShortTy{})
121 while (1);
122
123 HasInt HI{};
124 T MyT{};
125
126 #pragma acc parallel async(HI)
127 while (1);
128
129 #pragma acc kernels async(MyT)
130 while (1);
131 }
132
133 void Inst() {
134 TestInst<HasInt>(); // #INST
135 }