llvm-project/clang/test/SemaCXX/decomposition-openmp.cpp
Mike Rice de1ea787ed
[OpenMP] Move unsupported structured bindings diagnostic (#80216)
Move the diagnostic so it fires only when doing an OpenMP capture, not
for non-OpenMP captures. This allows non-OpenMP code to work when using
OpenMP elsewhere, such as the code reported in
https://github.com/llvm/llvm-project/issues/66999.
2024-02-01 10:07:23 -08:00

33 lines
639 B
C++

// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -fopenmp %s
// Okay, not an OpenMP capture.
auto f() {
int i[2] = {};
auto [a, b] = i;
return [=, &a] {
return a + b;
};
}
// Okay, not an OpenMP capture.
void foo(int);
void g() {
#pragma omp parallel
{
int i[2] = {};
auto [a, b] = i;
auto L = [&] { foo(a+b); };
}
}
// FIXME: OpenMP should support capturing structured bindings
void h() {
int i[2] = {};
auto [a, b] = i; // expected-note 2{{declared here}}
#pragma omp parallel
{
// expected-error@+1 2{{capturing a structured binding is not yet supported in OpenMP}}
foo(a + b);
}
}