1 // RUN: %clang_cc1 %s -fopenacc -verify
3 struct NotConvertible
{} NC
;
4 struct Incomplete
*SomeIncomplete
; // #INCOMPLETE
6 enum class E2
{} SomeE2
;
8 struct CorrectConvert
{
12 struct ExplicitConvertOnly
{
13 explicit operator int() const; // #EXPL_CONV
16 struct AmbiguousConvert
{
17 operator int(); // #AMBIG_INT
18 operator short(); // #AMBIG_SHORT
27 #pragma acc kernels num_gangs(1)
30 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
31 #pragma acc serial num_gangs(1)
34 #pragma acc parallel num_gangs(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())
41 #pragma acc parallel num_gangs(some_short(), some_int(), some_long())
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)
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)
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)
56 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
57 #pragma acc serial num_gangs(1, 2)
60 #pragma acc parallel num_gangs(1, 2)
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)
69 // expected-error@+1{{OpenACC clause 'num_gangs' requires expression of integer type ('struct NotConvertible' invalid)}}
70 #pragma acc parallel num_gangs(NC, SomeE)
73 // expected-error@+1{{OpenACC clause 'num_gangs' requires expression of integer type ('struct NotConvertible' invalid)}}
74 #pragma acc parallel num_gangs(SomeE, NC)
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)
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)
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)
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)
113 using ShortTy
= short;
114 static constexpr int value
= 1;
115 static constexpr AmbiguousConvert ACValue
;
116 static constexpr ExplicitConvertOnly EXValue
;
121 template <typename T
>
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)
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)
133 // expected-error@+1{{no member named 'Invalid' in 'HasInt'}}
134 #pragma acc parallel num_gangs(1, HasInt::Invalid)
137 // expected-error@+1{{no member named 'Invalid' in 'HasInt'}}
138 #pragma acc parallel num_gangs(T::Invalid, 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)
146 // expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}}
147 #pragma acc serial num_gangs(T::Invalid, 1)
150 #pragma acc parallel num_gangs(T::value, typename T::IntTy{})
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{})
159 TestInst
<HasInt
>(); // #INST