[libc++] Refactor the sequence container benchmarks (#119763)
[llvm-project.git] / clang / test / SemaOpenACC / compute-construct-self-clause.cpp
blob60edbdc2b1191bde55504143ab0f84381b493e4d
1 // RUN: %clang_cc1 %s -fopenacc -verify
3 struct NoBoolConversion{};
4 struct BoolConversion{
5 operator bool();
6 };
8 template <typename T, typename U>
9 void BoolExpr() {
10 // expected-error@+1{{value of type 'NoBoolConversion' is not contextually convertible to 'bool'}}
11 #pragma acc parallel self (NoBoolConversion{})
12 while(0);
13 // expected-error@+2{{no member named 'NotValid' in 'NoBoolConversion'}}
14 // expected-note@#INST{{in instantiation of function template specialization}}
15 #pragma acc parallel self (T::NotValid)
16 while(0);
18 #pragma acc parallel self (BoolConversion{})
19 while(0);
21 // expected-error@+1{{value of type 'NoBoolConversion' is not contextually convertible to 'bool'}}
22 #pragma acc parallel self (T{})
23 while(0);
25 #pragma acc parallel self (U{})
26 while(0);
29 struct HasBool {
30 static constexpr bool B = true;
33 template<typename T>
34 void WarnMaybeNotUsed() {
35 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
36 // expected-note@+1{{previous clause is here}}
37 #pragma acc parallel self if(T::B)
38 while(0);
40 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
41 // expected-note@+1{{previous clause is here}}
42 #pragma acc parallel self(T::B) if(T::B)
43 while(0);
45 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
46 // expected-note@+1{{previous clause is here}}
47 #pragma acc parallel if(T::B) self
48 while(0);
50 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
51 // expected-note@+1{{previous clause is here}}
52 #pragma acc parallel if(T::B) self(T::B)
53 while(0);
55 // We still warn in the cases of dependent failures, since the diagnostic
56 // happens immediately rather than during instantiation.
58 // expected-error@+4{{no member named 'Invalid' in 'HasBool'}}
59 // expected-note@#NOT_USED_INST{{in instantiation of function template specialization 'WarnMaybeNotUsed<HasBool>' requested here}}
60 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
61 // expected-note@+1{{previous clause is here}}
62 #pragma acc parallel self if(T::Invalid)
63 while(0);
65 // expected-error@+3{{no member named 'Invalid' in 'HasBool'}}
66 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
67 // expected-note@+1{{previous clause is here}}
68 #pragma acc parallel self(T::Invalid) if(T::B)
69 while(0);
71 // expected-error@+3{{no member named 'Invalid' in 'HasBool'}}
72 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
73 // expected-note@+1{{previous clause is here}}
74 #pragma acc parallel self(T::B) if(T::Invalid)
75 while(0);
77 // expected-error@+3{{no member named 'Invalid' in 'HasBool'}}
78 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
79 // expected-note@+1{{previous clause is here}}
80 #pragma acc parallel if(T::Invalid) self
81 while(0);
83 // expected-error@+3{{no member named 'Invalid' in 'HasBool'}}
84 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
85 // expected-note@+1{{previous clause is here}}
86 #pragma acc parallel if(T::Invalid) self(T::B)
87 while(0);
89 // expected-error@+3{{no member named 'Invalid' in 'HasBool'}}
90 // expected-warning@+2{{OpenACC construct 'self' has no effect when an 'if' clause evaluates to true}}
91 // expected-note@+1{{previous clause is here}}
92 #pragma acc parallel if(T::B) self(T::Invalid)
93 while(0);
96 void Instantiate() {
97 BoolExpr<NoBoolConversion, BoolConversion>(); // #INST
98 WarnMaybeNotUsed<HasBool>(); // #NOT_USED_INST