[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / SemaOpenACC / compute-construct-num_gangs-clause.cpp
blobec3df87a065572f71518fccb8384eb3e36043240
1 // RUN: %clang_cc1 %s -fopenacc -verify
3 struct NotConvertible{} NC;
4 struct Incomplete *SomeIncomplete; // #INCOMPLETE
5 enum E{} SomeE;
6 enum class E2{} SomeE2;
8 struct CorrectConvert {
9 operator int();
10 } Convert;
12 struct ExplicitConvertOnly {
13 explicit operator int() const; // #EXPL_CONV
14 } Explicit;
16 struct AmbiguousConvert{
17 operator int(); // #AMBIG_INT
18 operator short(); // #AMBIG_SHORT
19 operator float();
20 } Ambiguous;
22 short some_short();
23 int some_int();
24 long some_long();
26 void Test() {
27 #pragma acc kernels num_gangs(1)
28 while(1);
30 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
31 #pragma acc serial num_gangs(1)
32 while(1);
34 #pragma acc parallel num_gangs(1)
35 while(1);
37 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
38 #pragma acc serial num_gangs(some_short(), some_int(), some_long())
39 while(1);
41 #pragma acc parallel num_gangs(some_short(), some_int(), some_long())
42 while(1);
44 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
45 #pragma acc serial num_gangs(some_short(), some_int(), some_long(), SomeE)
46 while(1);
48 // expected-error@+1{{too many integer expression arguments provided to OpenACC 'num_gangs' clause: 'parallel' directive expects maximum of 3, 4 were provided}}
49 #pragma acc parallel num_gangs(some_short(), some_int(), some_long(), SomeE)
50 while(1);
52 // expected-error@+1{{too many integer expression arguments provided to OpenACC 'num_gangs' clause: 'kernels' directive expects maximum of 1, 2 were provided}}
53 #pragma acc kernels num_gangs(1, 2)
54 while(1);
56 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
57 #pragma acc serial num_gangs(1, 2)
58 while(1);
60 #pragma acc parallel num_gangs(1, 2)
61 while(1);
63 // expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}}
64 // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
65 // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
66 #pragma acc parallel num_gangs(Ambiguous)
67 while(1);
69 // expected-error@+1{{OpenACC clause 'num_gangs' requires expression of integer type ('struct NotConvertible' invalid)}}
70 #pragma acc parallel num_gangs(NC, SomeE)
71 while(1);
73 // expected-error@+1{{OpenACC clause 'num_gangs' requires expression of integer type ('struct NotConvertible' invalid)}}
74 #pragma acc parallel num_gangs(SomeE, NC)
75 while(1);
77 // expected-error@+3{{OpenACC integer expression type 'struct ExplicitConvertOnly' requires explicit conversion to 'int'}}
78 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
79 // expected-error@+1{{OpenACC clause 'num_gangs' requires expression of integer type ('struct NotConvertible' invalid)}}
80 #pragma acc parallel num_gangs(Explicit, NC)
81 while(1);
83 // expected-error@+4{{OpenACC integer expression type 'struct ExplicitConvertOnly' requires explicit conversion to 'int'}}
84 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
85 // expected-error@+2{{OpenACC clause 'num_gangs' requires expression of integer type ('struct NotConvertible' invalid)}}
86 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
87 #pragma acc serial num_gangs(Explicit, NC)
88 while(1);
90 // expected-error@+6{{OpenACC integer expression type 'struct ExplicitConvertOnly' requires explicit conversion to 'int'}}
91 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
92 // expected-error@+4{{OpenACC clause 'num_gangs' requires expression of integer type ('struct NotConvertible' invalid)}}
93 // expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}}
94 // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
95 // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
96 #pragma acc parallel num_gangs(Explicit, NC, Ambiguous)
97 while(1);
99 // expected-error@+7{{OpenACC integer expression type 'struct ExplicitConvertOnly' requires explicit conversion to 'int'}}
100 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
101 // expected-error@+5{{OpenACC clause 'num_gangs' requires expression of integer type ('struct NotConvertible' invalid)}}
102 // expected-error@+4{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}}
103 // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
104 // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
105 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
106 #pragma acc serial num_gangs(Explicit, NC, Ambiguous)
107 while(1);
108 // TODO
111 struct HasInt {
112 using IntTy = int;
113 using ShortTy = short;
114 static constexpr int value = 1;
115 static constexpr AmbiguousConvert ACValue;
116 static constexpr ExplicitConvertOnly EXValue;
118 operator char();
121 template <typename T>
122 void TestInst() {
123 // expected-error@+2{{no member named 'Invalid' in 'HasInt'}}
124 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
125 #pragma acc serial num_gangs(HasInt::Invalid)
126 while(1);
128 // expected-error@+2{{no member named 'Invalid' in 'HasInt'}}
129 // expected-note@#INST{{in instantiation of function template specialization}}
130 #pragma acc parallel num_gangs(T::Invalid)
131 while(1);
133 // expected-error@+1{{no member named 'Invalid' in 'HasInt'}}
134 #pragma acc parallel num_gangs(1, HasInt::Invalid)
135 while(1);
137 // expected-error@+1{{no member named 'Invalid' in 'HasInt'}}
138 #pragma acc parallel num_gangs(T::Invalid, 1)
139 while(1);
141 // expected-error@+2{{no member named 'Invalid' in 'HasInt'}}
142 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
143 #pragma acc serial num_gangs(1, HasInt::Invalid)
144 while(1);
146 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
147 #pragma acc serial num_gangs(T::Invalid, 1)
148 while(1);
150 #pragma acc parallel num_gangs(T::value, typename T::IntTy{})
151 while(1);
153 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
154 #pragma acc serial num_gangs(T::value, typename T::IntTy{})
155 while(1);
158 void Inst() {
159 TestInst<HasInt>(); // #INST