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