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