| 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 |
short some_short(); |
| 23 |
int some_int(); |
| 24 |
long some_long(); |
| 25 |
|
| 26 |
void Test() { |
| 27 |
#pragma acc kernels num_gangs(1) |
| 28 |
while(1); |
| 29 |
|
| 30 |
// expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}} |
| 31 |
#pragma acc serial num_gangs(1) |
| 32 |
while(1); |
| 33 |
|
| 34 |
#pragma acc parallel num_gangs(1) |
| 35 |
while(1); |
| 36 |
|
| 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); |
| 40 |
|
| 41 |
#pragma acc parallel num_gangs(some_short(), some_int(), some_long()) |
| 42 |
while(1); |
| 43 |
|
| 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); |
| 47 |
|
| 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); |
| 51 |
|
| 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); |
| 55 |
|
| 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); |
| 59 |
|
| 60 |
#pragma acc parallel num_gangs(1, 2) |
| 61 |
while(1); |
| 62 |
|
| 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); |
| 68 |
|
| 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); |
| 72 |
|
| 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); |
| 76 |
|
| 77 |
// expected-error@+3{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' 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); |
| 82 |
|
| 83 |
// expected-error@+4{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' 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); |
| 89 |
|
| 90 |
// expected-error@+6{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' 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); |
| 98 |
|
| 99 |
// expected-error@+7{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' 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 |
} |
| 109 |
|
| 110 |
struct HasInt { |
| 111 |
using IntTy = int; |
| 112 |
using ShortTy = short; |
| 113 |
static constexpr int value = 1; |
| 114 |
static constexpr AmbiguousConvert ACValue; |
| 115 |
static constexpr ExplicitConvertOnly EXValue; |
| 116 |
|
| 117 |
operator char(); |
| 118 |
}; |
| 119 |
|
| 120 |
template <typename T> |
| 121 |
void TestInst() { |
| 122 |
// expected-error@+1{{no member named 'Invalid' in 'HasInt'}} |
| 123 |
#pragma acc serial num_gangs(HasInt::Invalid) |
| 124 |
while(1); |
| 125 |
|
| 126 |
// expected-error@+2{{no member named 'Invalid' in 'HasInt'}} |
| 127 |
// expected-note@#INST{{in instantiation of function template specialization}} |
| 128 |
#pragma acc parallel num_gangs(T::Invalid) |
| 129 |
while(1); |
| 130 |
|
| 131 |
// expected-error@+1{{no member named 'Invalid' in 'HasInt'}} |
| 132 |
#pragma acc parallel num_gangs(1, HasInt::Invalid) |
| 133 |
while(1); |
| 134 |
|
| 135 |
// expected-error@+1{{no member named 'Invalid' in 'HasInt'}} |
| 136 |
#pragma acc parallel num_gangs(T::Invalid, 1) |
| 137 |
while(1); |
| 138 |
|
| 139 |
// expected-error@+1{{no member named 'Invalid' in 'HasInt'}} |
| 140 |
#pragma acc serial num_gangs(1, HasInt::Invalid) |
| 141 |
while(1); |
| 142 |
|
| 143 |
// expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}} |
| 144 |
#pragma acc serial num_gangs(T::Invalid, 1) |
| 145 |
while(1); |
| 146 |
|
| 147 |
#pragma acc parallel num_gangs(T::value, typename T::IntTy{}) |
| 148 |
while(1); |
| 149 |
|
| 150 |
// expected-error@+1{{OpenACC 'num_gangs' clause is not valid on 'serial' directive}} |
| 151 |
#pragma acc serial num_gangs(T::value, typename T::IntTy{}) |
| 152 |
while(1); |
| 153 |
} |
| 154 |
|
| 155 |
void Inst() { |
| 156 |
TestInst<HasInt>(); // #INST |
| 157 |
} |