xref: /llvm-project/clang/test/ParserOpenACC/parse-clauses.cpp (revision 1ab81f8e7f77110c4a752dd7d2cc39fb5148760c)
1 // RUN: %clang_cc1 %s -verify -fopenacc
2 
3 template<unsigned I, typename T>
4 void templ() {
5 #pragma acc loop collapse(I)
6   for(int i = 0; i < 5;++i)
7     for(int j = 0; j < 5; ++j)
8       for(int k = 0; k < 5; ++k)
9         for(int l = 0; l < 5; ++l)
10           for(int m = 0; m < 5; ++m)
11             for(int n = 0; n < 5; ++n)
12               for(int o = 0; o < 5; ++o);
13 
14 #pragma acc loop collapse(T::value)
15   for(int i = 0;i < 5;++i)
16     for(int j = 0; j < 5; ++j)
17       for(int k = 0; k < 5; ++k)
18         for(int l = 0; l < 5; ++l)
19           for(int m = 0; m < 5;++m)
20             for(;;)
21               for(;;);
22 
23 #pragma acc parallel vector_length(T::value)
24   for(;;){}
25 
26 #pragma acc parallel vector_length(I)
27   for(;;){}
28 
29 #pragma acc parallel async(T::value)
30   for(;;){}
31 
32 #pragma acc parallel async(I)
33   for(;;){}
34 
35 #pragma acc parallel async
36   for(;;){}
37 
38 
39   T t;
40 #pragma acc exit data delete(t)
41   ;
42 }
43 
44 struct S {
45   static constexpr unsigned value = 5;
46 };
47 
48 void use() {
49   templ<7, S>();
50 }
51 
52 namespace NS {
53 void NSFunc();
54 
55 class RecordTy { // #RecTy
56   static constexpr bool Value = false; // #VAL
57   void priv_mem_function(); // #PrivMemFun
58   public:
59   static constexpr bool ValuePub = true;
60   void mem_function();
61 };
62 template<typename T>
63 class TemplTy{};
64 void function();
65 }
66 
67 
68   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
69   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
70 #pragma acc routine(use) bind(NS::NSFunc)
71   // expected-error@+3{{'RecordTy' does not refer to a value}}
72   // expected-note@#RecTy{{declared here}}
73   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
74 #pragma acc routine(use) bind(NS::RecordTy)
75   // expected-error@+4{{'Value' is a private member of 'NS::RecordTy'}}
76   // expected-note@#VAL{{implicitly declared private here}}
77   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
78   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
79 #pragma acc routine(use) bind(NS::RecordTy::Value)
80   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
81   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
82 #pragma acc routine(use) bind(NS::RecordTy::ValuePub)
83   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
84   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
85 #pragma acc routine(use) bind(NS::TemplTy<int>)
86   // expected-error@+2{{no member named 'unknown' in namespace 'NS'}}
87   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
88 #pragma acc routine(use) bind(NS::unknown<int>)
89   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
90   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
91 #pragma acc routine(use) bind(NS::function)
92   // expected-error@+4{{'priv_mem_function' is a private member of 'NS::RecordTy'}}
93   // expected-note@#PrivMemFun{{implicitly declared private here}}
94   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
95   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
96 #pragma acc routine(use) bind(NS::RecordTy::priv_mem_function)
97   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
98   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
99 #pragma acc routine(use) bind(NS::RecordTy::mem_function)
100 
101   // expected-error@+2{{string literal with user-defined suffix cannot be used here}}
102   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
103 #pragma acc routine(use) bind("unknown udl"_UDL)
104 
105   // expected-warning@+3{{encoding prefix 'u' on an unevaluated string literal has no effect}}
106   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
107   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
108 #pragma acc routine(use) bind(u"16 bits")
109   // expected-warning@+3{{encoding prefix 'U' on an unevaluated string literal has no effect}}
110   // expected-warning@+2{{OpenACC clause 'bind' not yet implemented, clause ignored}}
111   // expected-warning@+1{{OpenACC construct 'routine' not yet implemented, pragma ignored}}
112 #pragma acc routine(use) bind(U"32 bits")
113