| 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 set default_async(getI()) |
| 19 |
#pragma acc set device_num(getI()) |
| 20 |
#pragma acc set device_type(multicore) |
| 21 |
#pragma acc set device_type(host) if (getI() < getS()) |
| 22 |
|
| 23 |
// expected-error@+1{{value of type 'struct NotConvertible' is not contextually convertible to 'bool'}} |
| 24 |
#pragma acc set if (NC) device_type(radeon) |
| 25 |
|
| 26 |
// expected-error@+2{{OpenACC 'set' construct must have at least one 'default_async', 'device_num', or 'device_type' clause}} |
| 27 |
// expected-error@+1{{OpenACC clause 'device_num' requires expression of integer type ('struct NotConvertible' invalid)}} |
| 28 |
#pragma acc set device_num(NC) |
| 29 |
// expected-error@+4{{OpenACC 'set' construct must have at least one 'default_async', 'device_num', or 'device_type' clause}} |
| 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 set 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 set device_num(Explicit) |
| 37 |
|
| 38 |
// expected-error@+2{{OpenACC clause 'default_async' requires expression of integer type ('struct NotConvertible' invalid)}} |
| 39 |
// expected-error@+1{{OpenACC 'set' construct must have at least one 'default_async', 'device_num', or 'device_type' clause}} |
| 40 |
#pragma acc set default_async(NC) |
| 41 |
// expected-error@+4{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}} |
| 42 |
// expected-note@#AMBIG_INT{{conversion to integral type 'int'}} |
| 43 |
// expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} |
| 44 |
// expected-error@+1{{OpenACC 'set' construct must have at least one 'default_async', 'device_num', or 'device_type' clause}} |
| 45 |
#pragma acc set default_async(Ambiguous) |
| 46 |
// expected-error@+2{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' to 'int'}} |
| 47 |
// expected-note@#EXPL_CONV{{conversion to integral type 'int'}} |
| 48 |
#pragma acc set default_async(Explicit) |
| 49 |
|
| 50 |
// expected-error@+1{{OpenACC 'set' construct must have at least one 'default_async', 'device_num', or 'device_type' clause}} |
| 51 |
#pragma acc set |
| 52 |
|
| 53 |
// expected-error@+1{{OpenACC 'set' construct must have at least one 'default_async', 'device_num', or 'device_type' clause}} |
| 54 |
#pragma acc set if (true) |
| 55 |
|
| 56 |
// expected-error@+2{{'default_async' clause cannot appear more than once on a 'set' directive}} |
| 57 |
// expected-note@+1{{previous 'default_async' clause is here}} |
| 58 |
#pragma acc set default_async(getI()) default_async(getI()) |
| 59 |
|
| 60 |
// expected-error@+2{{'device_num' clause cannot appear more than once on a 'set' directive}} |
| 61 |
// expected-note@+1{{previous 'device_num' clause is here}} |
| 62 |
#pragma acc set device_num(getI()) device_num(getI()) |
| 63 |
|
| 64 |
// expected-error@+2{{'device_type' clause cannot appear more than once on a 'set' directive}} |
| 65 |
// expected-note@+1{{previous 'device_type' clause is here}} |
| 66 |
#pragma acc set device_type(nvidia) device_type(default) |
| 67 |
// expected-error@+2{{'if' clause cannot appear more than once on a 'set' directive}} |
| 68 |
// expected-note@+1{{previous 'if' clause is here}} |
| 69 |
#pragma acc set device_type(acc_device_nvidia) if(true) if (true) |
| 70 |
|
| 71 |
// expected-error@+2{{OpenACC 'device_type' clause on a 'set' construct only permits one architecture}} |
| 72 |
// expected-error@+1{{OpenACC 'set' construct must have at least one 'default_async', 'device_num', or 'device_type' clause}} |
| 73 |
#pragma acc set device_type(nvidia, radeon) |
| 74 |
|
| 75 |
// expected-error@+2{{OpenACC 'device_type' clause on a 'set' construct only permits one architecture}} |
| 76 |
// expected-error@+1{{OpenACC 'set' construct must have at least one 'default_async', 'device_num', or 'device_type' clause}} |
| 77 |
#pragma acc set device_type(nonsense, nvidia, radeon) |
| 78 |
} |