https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118694
--- Comment #4 from sandra at gcc dot gnu.org --- The nesting error is diagnosed in omp-low.cc. By this time the gimplifier has already replaced the metadirective with a conditional. Since it's a static selector, it'll be resolved to a constant during the ompdevlow pass, allowing the conditional to be optimized away. This can only happen when the metadirective selector is static and involves a "device" selector in a configuration where it *might* match. Dynamic selectors are not allowed, and the other case for static selectors that requires late resolution (a "construct" selector that can't be scored) doesn't apply here because of the enclosing #omp target directive. I thought briefly about refactoring the code in the gimplifier to duplicate the enclosing #omp target into the arms of the conditional, but that would screw up the resolution of the "device" selector and I don't think it's always statically resolvable by examining the clauses on the #omp target. I need to do some more investigation to discover if it will generate correct code if the bogus error is disabled. In that case the diagnostic could be moved to the gimplifier, or the gimplifier could emit some sort of new marker to enclose the metadirective expansion, without otherwise changing the expansion. Otherwise I have no ideas as yet. :-(