| 1 |
// RUN: %clang_cc1 %s -fopenacc -verify |
| 2 |
|
| 3 |
struct NotConvertible{} NC; |
| 4 |
short getS(); |
| 5 |
int getI(); |
| 6 |
|
| 7 |
struct AmbiguousConvert{ |
| 8 |
operator int(); // #AMBIG_INT |
| 9 |
operator short(); // #AMBIG_SHORT |
| 10 |
operator float(); |
| 11 |
} Ambiguous; |
| 12 |
|
| 13 |
struct ExplicitConvertOnly { |
| 14 |
explicit operator int() const; // #EXPL_CONV |
| 15 |
} Explicit; |
| 16 |
|
| 17 |
void uses() { |
| 18 |
int arr[5]; |
| 19 |
#pragma acc wait(getS(), getI()) |
| 20 |
#pragma acc wait(devnum:getS(): getI()) |
| 21 |
#pragma acc wait(devnum:getS(): queues: getI(), getS()) |
| 22 |
#pragma acc wait(devnum:getS(): getI(), getS()) |
| 23 |
|
| 24 |
// expected-error@+1{{OpenACC directive 'wait' requires expression of integer type ('struct NotConvertible' invalid)}} |
| 25 |
#pragma acc wait(devnum:NC : 5) |
| 26 |
// expected-error@+1{{OpenACC directive 'wait' requires expression of integer type ('struct NotConvertible' invalid)}} |
| 27 |
#pragma acc wait(devnum:5 : NC) |
| 28 |
// expected-error@+3{{OpenACC directive 'wait' requires expression of integer type ('int[5]' invalid)}} |
| 29 |
// expected-error@+2{{OpenACC directive 'wait' requires expression of integer type ('int[5]' invalid)}} |
| 30 |
// expected-error@+1{{OpenACC directive 'wait' requires expression of integer type ('struct NotConvertible' invalid)}} |
| 31 |
#pragma acc wait(devnum:arr : queues: arr, NC, 5) |
| 32 |
|
| 33 |
// expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}} |
| 34 |
// expected-note@#AMBIG_INT{{conversion to integral type 'int'}} |
| 35 |
// expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} |
| 36 |
#pragma acc wait(Ambiguous) |
| 37 |
|
| 38 |
// expected-error@+2{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' to 'int'}} |
| 39 |
// expected-note@#EXPL_CONV{{conversion to integral type 'int'}} |
| 40 |
#pragma acc wait(4, Explicit, 5) |
| 41 |
|
| 42 |
// expected-error@+1{{use of undeclared identifier 'queues'}} |
| 43 |
#pragma acc wait(devnum: queues: 5) |
| 44 |
|
| 45 |
#pragma acc wait async |
| 46 |
#pragma acc wait async(getI()) |
| 47 |
// expected-error@+1{{OpenACC clause 'async' requires expression of integer type ('struct NotConvertible' invalid)}} |
| 48 |
#pragma acc wait async(NC) |
| 49 |
|
| 50 |
#pragma acc wait if(getI() < getS()) |
| 51 |
// expected-error@+1{{value of type 'struct NotConvertible' is not contextually convertible to 'bool'}} |
| 52 |
#pragma acc wait if(NC) |
| 53 |
|
| 54 |
} |
| 55 |
|
| 56 |
template<typename T> |
| 57 |
void TestInst() { |
| 58 |
// expected-error@+4{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}} |
| 59 |
// expected-note@#INST{{in instantiation of function template specialization}} |
| 60 |
// expected-note@#AMBIG_INT{{conversion to integral type 'int'}} |
| 61 |
// expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} |
| 62 |
#pragma acc wait(devnum:T::value :queues:T::ACValue) |
| 63 |
|
| 64 |
// expected-error@+5{{OpenACC integer expression requires explicit conversion from 'const ExplicitConvertOnly' to 'int'}} |
| 65 |
// expected-note@#EXPL_CONV{{conversion to integral type 'int'}} |
| 66 |
// expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}} |
| 67 |
// expected-note@#AMBIG_INT{{conversion to integral type 'int'}} |
| 68 |
// expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} |
| 69 |
#pragma acc wait(devnum:T::EXValue :queues:T::ACValue) |
| 70 |
|
| 71 |
// expected-error@+1{{no member named 'Invalid' in 'HasInt'}} |
| 72 |
#pragma acc wait(queues: T::Invalid, T::Invalid2) |
| 73 |
|
| 74 |
// expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}} |
| 75 |
// expected-note@#AMBIG_INT{{conversion to integral type 'int'}} |
| 76 |
// expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} |
| 77 |
#pragma acc wait async(T::ACValue) |
| 78 |
|
| 79 |
#pragma acc wait if(T::value < T{}) |
| 80 |
// expected-error@+1{{value of type 'const ExplicitConvertOnly' is not contextually convertible to 'bool'}} |
| 81 |
#pragma acc wait if(T::EXValue) |
| 82 |
} |
| 83 |
|
| 84 |
struct HasInt { |
| 85 |
using IntTy = int; |
| 86 |
using ShortTy = short; |
| 87 |
static constexpr int value = 1; |
| 88 |
static constexpr AmbiguousConvert ACValue; |
| 89 |
static constexpr ExplicitConvertOnly EXValue; |
| 90 |
|
| 91 |
operator char(); |
| 92 |
}; |
| 93 |
void Inst() { |
| 94 |
TestInst<HasInt>(); // #INST |
| 95 |
} |