On February 10, 2025, Sandra Loosemore wrote:
The "begin declare variant" has different rules for determining whether a context selector cannot match for purposes of code elision than we normally use; it excludes the case of a constant false "condition" selector for the "user" set.
Namely: "If the context selector of a begin declare_variant directive contains traits in the 'device' or 'implementation' set that are known never to be compatible with an OpenMP context ... the preprocessed code ... is elided." [Which in turn means that 'target_device', 'user' and 'construct' won't be elided. Construct depends on the call side and cannot be elided, the others sometimes could. In particular, if the condition expression is a constant expression/constexpr evaluating to false, it could. Why it has been excluded is unclear, given that it can be useful at times. But as it has, let's honor it.]
gcc/ChangeLog * omp-general.cc (omp_context_selector_matches): Add an optional bool argument for the code elision case. * omp-general.h (omp_context_selector_matches): Likewise.
LGTM. Thanks, Tobias