105 lines · cpp
1// RUN: %clang_cc1 %s -fopenacc -verify2 3struct ExplicitConvertOnly {4 explicit operator int() const; // #EXPL_CONV5} Explicit;6 7struct AmbiguousConvert{8 operator int(); // #AMBIG_INT9 operator short(); // #AMBIG_SHORT10 operator float();11} Ambiguous;12 13void Test() {14 15 // expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}}16 // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}17 // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}18#pragma acc parallel wait(Ambiguous)19 while (true);20 21 // expected-error@+2{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' to 'int'}}22 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}23#pragma acc parallel wait(4, Explicit, 5)24 while (true);25 26 // expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}}27 // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}28 // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}29#pragma acc parallel wait(queues: Ambiguous, 5)30 while (true);31 32 // expected-error@+2{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' to 'int'}}33 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}34#pragma acc parallel wait(devnum: Explicit: 5)35 while (true);36 37 // expected-error@+2{{OpenACC integer expression requires explicit conversion from 'struct ExplicitConvertOnly' to 'int'}}38 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}39#pragma acc parallel wait(devnum: Explicit:queues: 5)40 while (true);41 42 // expected-error@+1{{use of undeclared identifier 'queues'}}43#pragma acc parallel wait(devnum: queues: 5)44 while (true);45}46 47struct HasInt {48 using IntTy = int;49 using ShortTy = short;50 static constexpr int value = 1;51 static constexpr AmbiguousConvert ACValue;52 static constexpr ExplicitConvertOnly EXValue;53 54 operator char();55};56 57template<typename T>58void TestInst() {59 60#pragma acc parallel wait(T{})61 while (true);62 63#pragma acc parallel wait(devnum:typename T::ShortTy{}:queues:typename T::IntTy{})64 while (true);65 66 // expected-error@+4{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}}67 // expected-note@#INST{{in instantiation of function template specialization}}68 // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}69 // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}70#pragma acc parallel wait(devnum:T::value :queues:T::ACValue)71 while (true);72 73 // expected-error@+5{{OpenACC integer expression requires explicit conversion from 'const ExplicitConvertOnly' to 'int'}}74 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}75 // expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}}76 // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}77 // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}78#pragma acc parallel wait(devnum:T::EXValue :queues:T::ACValue)79 while (true);80 81 // expected-error@+5{{OpenACC integer expression requires explicit conversion from 'const ExplicitConvertOnly' to 'int'}}82 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}83 // expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}}84 // expected-note@#AMBIG_INT{{conversion to integral type 'int'}}85 // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}86#pragma acc parallel wait(T::EXValue, T::ACValue)87 while (true);88 89 // expected-error@+5{{OpenACC integer expression requires explicit conversion from 'const ExplicitConvertOnly' to 'int'}}90 // expected-note@#EXPL_CONV{{conversion to integral type 'int'}}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 parallel wait(queues: T::EXValue, T::ACValue)95 while (true);96 97 // expected-error@+1{{no member named 'Invalid' in 'HasInt'}}98#pragma acc parallel wait(queues: T::Invalid, T::Invalid2)99 while (true);100}101 102void Inst() {103 TestInst<HasInt>(); // #INST104}105