xref: /llvm-project/clang/test/ParserOpenACC/parse-clauses.cpp (revision 1ab81f8e7f77110c4a752dd7d2cc39fb5148760c)
13a82a1c3Serichkeane // RUN: %clang_cc1 %s -verify -fopenacc
23a82a1c3Serichkeane 
33a82a1c3Serichkeane template<unsigned I, typename T>
43a82a1c3Serichkeane void templ() {
53a82a1c3Serichkeane #pragma acc loop collapse(I)
6b0cfbfd7SErich Keane   for(int i = 0; i < 5;++i)
7b0cfbfd7SErich Keane     for(int j = 0; j < 5; ++j)
8b0cfbfd7SErich Keane       for(int k = 0; k < 5; ++k)
9b0cfbfd7SErich Keane         for(int l = 0; l < 5; ++l)
10b0cfbfd7SErich Keane           for(int m = 0; m < 5; ++m)
11b0cfbfd7SErich Keane             for(int n = 0; n < 5; ++n)
12b0cfbfd7SErich Keane               for(int o = 0; o < 5; ++o);
133a82a1c3Serichkeane 
143a82a1c3Serichkeane #pragma acc loop collapse(T::value)
15b0cfbfd7SErich Keane   for(int i = 0;i < 5;++i)
16b0cfbfd7SErich Keane     for(int j = 0; j < 5; ++j)
17b0cfbfd7SErich Keane       for(int k = 0; k < 5; ++k)
18b0cfbfd7SErich Keane         for(int l = 0; l < 5; ++l)
19b0cfbfd7SErich Keane           for(int m = 0; m < 5;++m)
2097da34e0SErich Keane             for(;;)
2197da34e0SErich Keane               for(;;);
220d8e333aSerichkeane 
230d8e333aSerichkeane #pragma acc parallel vector_length(T::value)
240d8e333aSerichkeane   for(;;){}
250d8e333aSerichkeane 
260d8e333aSerichkeane #pragma acc parallel vector_length(I)
270d8e333aSerichkeane   for(;;){}
2862a384caSerichkeane 
2962a384caSerichkeane #pragma acc parallel async(T::value)
3062a384caSerichkeane   for(;;){}
3162a384caSerichkeane 
3262a384caSerichkeane #pragma acc parallel async(I)
3362a384caSerichkeane   for(;;){}
3430cfe2b2Serichkeane 
3530cfe2b2Serichkeane #pragma acc parallel async
3630cfe2b2Serichkeane   for(;;){}
37ee090cb8Serichkeane 
38*1ab81f8eSerichkeane 
39*1ab81f8eSerichkeane   T t;
40*1ab81f8eSerichkeane #pragma acc exit data delete(t)
41ee090cb8Serichkeane   ;
423a82a1c3Serichkeane }
433a82a1c3Serichkeane 
443a82a1c3Serichkeane struct S {
453a82a1c3Serichkeane   static constexpr unsigned value = 5;
463a82a1c3Serichkeane };
473a82a1c3Serichkeane 
483a82a1c3Serichkeane void use() {
493a82a1c3Serichkeane   templ<7, S>();
503a82a1c3Serichkeane }
5158b77b85Serichkeane 
5258b77b85Serichkeane namespace NS {
5358b77b85Serichkeane void NSFunc();
5458b77b85Serichkeane 
5558b77b85Serichkeane class RecordTy { // #RecTy
5658b77b85Serichkeane   static constexpr bool Value = false; // #VAL
5758b77b85Serichkeane   void priv_mem_function(); // #PrivMemFun
5858b77b85Serichkeane   public:
5958b77b85Serichkeane   static constexpr bool ValuePub = true;
6058b77b85Serichkeane   void mem_function();
6158b77b85Serichkeane };
6258b77b85Serichkeane template<typename T>
6358b77b85Serichkeane class TemplTy{};
6458b77b85Serichkeane void function();
6558b77b85Serichkeane }
6658b77b85Serichkeane 
6758b77b85Serichkeane 
68db4ea21dSerichkeane   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
69db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
7058b77b85Serichkeane #pragma acc routine(use) bind(NS::NSFunc)
7126fee0ffSErich Keane   // expected-error@+3{{'RecordTy' does not refer to a value}}
7258b77b85Serichkeane   // expected-note@#RecTy{{declared here}}
73db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
7458b77b85Serichkeane #pragma acc routine(use) bind(NS::RecordTy)
75db4ea21dSerichkeane   // expected-error@+4{{'Value' is a private member of 'NS::RecordTy'}}
7658b77b85Serichkeane   // expected-note@#VAL{{implicitly declared private here}}
77db4ea21dSerichkeane   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
78db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
7958b77b85Serichkeane #pragma acc routine(use) bind(NS::RecordTy::Value)
80db4ea21dSerichkeane   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
81db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
8258b77b85Serichkeane #pragma acc routine(use) bind(NS::RecordTy::ValuePub)
83db4ea21dSerichkeane   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
84db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
8558b77b85Serichkeane #pragma acc routine(use) bind(NS::TemplTy<int>)
8626fee0ffSErich Keane   // expected-error@+2{{no member named 'unknown' in namespace 'NS'}}
87db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
8858b77b85Serichkeane #pragma acc routine(use) bind(NS::unknown<int>)
89db4ea21dSerichkeane   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
90db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
9158b77b85Serichkeane #pragma acc routine(use) bind(NS::function)
92db4ea21dSerichkeane   // expected-error@+4{{'priv_mem_function' is a private member of 'NS::RecordTy'}}
9358b77b85Serichkeane   // expected-note@#PrivMemFun{{implicitly declared private here}}
94db4ea21dSerichkeane   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
95db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
9658b77b85Serichkeane #pragma acc routine(use) bind(NS::RecordTy::priv_mem_function)
97db4ea21dSerichkeane   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
98db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
9958b77b85Serichkeane #pragma acc routine(use) bind(NS::RecordTy::mem_function)
10058b77b85Serichkeane 
10126fee0ffSErich Keane   // expected-error@+2{{string literal with user-defined suffix cannot be used here}}
102db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
10358b77b85Serichkeane #pragma acc routine(use) bind("unknown udl"_UDL)
10458b77b85Serichkeane 
105db4ea21dSerichkeane   // expected-warning@+3{{encoding prefix 'u' on an unevaluated string literal has no effect}}
106db4ea21dSerichkeane   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
107db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
10858b77b85Serichkeane #pragma acc routine(use) bind(u"16 bits")
109db4ea21dSerichkeane   // expected-warning@+3{{encoding prefix 'U' on an unevaluated string literal has no effect}}
110db4ea21dSerichkeane   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
111db4ea21dSerichkeane   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
11258b77b85Serichkeane #pragma acc routine(use) bind(U"32 bits")
113