llvm-project/clang/test/SemaOpenACC/compute-construct-if-clause.cpp
Erich Keane daa88364df
[OpenACC] Implement 'if' clause for Compute Constructs (#88411)
Like with the 'default' clause, this is being applied to only Compute
Constructs for now. The 'if' clause takes a condition expression which
is used as a runtime value.

This is not a particularly complex semantic implementation, as there
isn't much to this clause, other than its interactions with 'self',
  which will be managed in the patch to implement that.
2024-04-12 14:13:31 -07:00

34 lines
858 B
C++

// RUN: %clang_cc1 %s -fopenacc -verify
struct NoBoolConversion{};
struct BoolConversion{
operator bool();
};
template <typename T, typename U>
void BoolExpr() {
// expected-error@+1{{value of type 'NoBoolConversion' is not contextually convertible to 'bool'}}
#pragma acc parallel if (NoBoolConversion{})
while(0);
// expected-error@+2{{no member named 'NotValid' in 'NoBoolConversion'}}
// expected-note@#INST{{in instantiation of function template specialization}}
#pragma acc parallel if (T::NotValid)
while(0);
#pragma acc parallel if (BoolConversion{})
while(0);
// expected-error@+1{{value of type 'NoBoolConversion' is not contextually convertible to 'bool'}}
#pragma acc parallel if (T{})
while(0);
#pragma acc parallel if (U{})
while(0);
}
void Instantiate() {
BoolExpr<NoBoolConversion, BoolConversion>(); // #INST
}