mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 17:46:49 +00:00

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.
33 lines
639 B
C++
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);
|
|
}
|
|
}
|