| 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 |
#pragma acc shutdown |
| 19 |
#pragma acc shutdown if (getI() < getS()) |
| 20 |
#pragma acc shutdown device_num(getI()) |
| 21 |
#pragma acc shutdown device_type(host) device_num(getI()) |
| 22 |
#pragma acc shutdown device_type(nvidia) if (getI() < getS()) |
| 23 |
#pragma acc shutdown device_type(radeon) device_num(getI()) if (getI() < getS()) |
| 24 |
|
| 25 |
// expected-error@+1{{value of type 'struct NotConvertible' is not contextually convertible to 'bool'}} |
| 26 |
#pragma acc shutdown if (NC) |
| 27 |
|
| 28 |
// expected-error@+1{{OpenACC clause 'device_num' requires expression of integer type ('struct NotConvertible' invalid)}} |
| 29 |
#pragma acc shutdown device_num(NC) |
| 30 |
// expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}} |
| 31 |
// expected-note@#AMBIG_INT{{conversion to integral type 'int'}} |
| 32 |
// expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} |
| 33 |
#pragma acc shutdown device_num(Ambiguous) |
| 34 |
// expected-error@+2{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' to 'int'}} |
| 35 |
// expected-note@#EXPL_CONV{{conversion to integral type 'int'}} |
| 36 |
#pragma acc shutdown device_num(Explicit) |
| 37 |
|
| 38 |
// expected-error@+1{{OpenACC 'device_type' clause on a 'shutdown' construct only permits one architecture}} |
| 39 |
#pragma acc shutdown device_type(nvidia, radeon) |
| 40 |
|
| 41 |
// expected-error@+1{{OpenACC 'device_type' clause on a 'shutdown' construct only permits one architecture}} |
| 42 |
#pragma acc shutdown device_type(nonsense, nvidia, radeon) |
| 43 |
} |
| 44 |
|
| 45 |
template<typename T> |
| 46 |
void TestInst() { |
| 47 |
T t; |
| 48 |
#pragma acc shutdown |
| 49 |
#pragma acc shutdown if (T::value < T{}) |
| 50 |
#pragma acc shutdown device_type(multicore) device_num(getI()) if (getI() < getS()) |
| 51 |
// expected-error@+2{{OpenACC 'device_num' clause cannot appear more than once on a 'shutdown' directive}} |
| 52 |
// expected-note@+1{{previous 'device_num' clause is here}} |
| 53 |
#pragma acc shutdown device_type(default) device_type(radeon) device_num(t) if (t < T::value) device_num(getI()) |
| 54 |
|
| 55 |
// expected-error@+1{{value of type 'const NotConvertible' is not contextually convertible to 'bool'}} |
| 56 |
#pragma acc shutdown if (T::NCValue) |
| 57 |
|
| 58 |
// expected-error@+2{{OpenACC 'if' clause cannot appear more than once on a 'shutdown' directive}} |
| 59 |
// expected-note@+1{{previous 'if' clause is here}} |
| 60 |
#pragma acc shutdown if(t < T::value) if (getI() < getS()) |
| 61 |
|
| 62 |
// expected-error@+1{{OpenACC clause 'device_num' requires expression of integer type ('const NotConvertible' invalid)}} |
| 63 |
#pragma acc shutdown device_num(T::NCValue) |
| 64 |
// expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}} |
| 65 |
// expected-note@#AMBIG_INT{{conversion to integral type 'int'}} |
| 66 |
// expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} |
| 67 |
#pragma acc shutdown device_num(T::ACValue) |
| 68 |
// expected-error@+2{{OpenACC integer expression requires explicit conversion from 'const ExplicitConvertOnly' to 'int'}} |
| 69 |
// expected-note@#EXPL_CONV{{conversion to integral type 'int'}} |
| 70 |
#pragma acc shutdown device_num(T::EXValue) |
| 71 |
} |
| 72 |
|
| 73 |
struct HasStuff { |
| 74 |
static constexpr AmbiguousConvert ACValue; |
| 75 |
static constexpr ExplicitConvertOnly EXValue; |
| 76 |
static constexpr NotConvertible NCValue; |
| 77 |
static constexpr unsigned value = 5; |
| 78 |
operator char(); |
| 79 |
}; |
| 80 |
|
| 81 |
void Inst() { |
| 82 |
TestInst<HasStuff>(); // expected-note {{in instantiation of function template specialization}} |
| 83 |
} |