[libc++] Refactor the sequence container benchmarks (#119763)
[llvm-project.git] / clang / test / SemaOpenACC / combined-construct-self-clause.cpp
blob73f5a55d77c31b238075f1dafe69fd09030fc0bd
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 loop self (NoBoolConversion{})
12 for (unsigned i = 0; i < 5; ++i);
13 // expected-error@+2{{no member named 'NotValid' in 'NoBoolConversion'}}
14 // expected-note@#INST{{in instantiation of function template specialization}}
15 #pragma acc serial loop self (T::NotValid)
16 for (unsigned i = 0; i < 5; ++i);
18 #pragma acc kernels loop self (BoolConversion{})
19 for (unsigned i = 0; i < 5; ++i);
21 // expected-error@+1{{value of type 'NoBoolConversion' is not contextually convertible to 'bool'}}
22 #pragma acc parallel loop self (T{})
23 for (unsigned i = 0; i < 5; ++i);
25 #pragma acc parallel loop self (U{})
26 for (unsigned i = 0; i < 5; ++i);
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 loop self if(T::B)
38 for (unsigned i = 0; i < 5; ++i);
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 kernels loop self(T::B) if(T::B)
43 for (unsigned i = 0; i < 5; ++i);
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 serial loop if(T::B) self
48 for (unsigned i = 0; i < 5; ++i);
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 loop if(T::B) self(T::B)
53 for (unsigned i = 0; i < 5; ++i);
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 loop self if(T::Invalid)
63 for (unsigned i = 0; i < 5; ++i);
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 serial loop self(T::Invalid) if(T::B)
69 for (unsigned i = 0; i < 5; ++i);
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 kernels loop self(T::B) if(T::Invalid)
75 for (unsigned i = 0; i < 5; ++i);
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 loop if(T::Invalid) self
81 for (unsigned i = 0; i < 5; ++i);
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 loop if(T::Invalid) self(T::B)
87 for (unsigned i = 0; i < 5; ++i);
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 loop if(T::B) self(T::Invalid)
93 for (unsigned i = 0; i < 5; ++i);
96 void Instantiate() {
97 BoolExpr<NoBoolConversion, BoolConversion>(); // #INST
98 WarnMaybeNotUsed<HasBool>(); // #NOT_USED_INST