https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120180
--- Comment #4 from sandra at gcc dot gnu.org --- I have a patch that fixes the ICE (not fully tested on an offload target yet, though). The issue of whether a metadirective is supposed to be accepted in a loop nest is completely separate from the ICE. In terms of the C/C++ front ends, special-casing the loop transformation directives happens explicitly when parsing a loop nest. I think we could make it work for the case where the metadirective can be resolved immediately to a directive with a static selector in the parser (e.g., the "condition" expression is a constant and there are no other selectors), but I'm skeptical whether it could be done in combination with gimplify-time resolution and I'm pretty sure it's hopeless if the metadirective needs late resolution in ompdevlow. I'm also pretty sure that anything uses a dynamic selector is not permitted per the first two bullet points at the bottom of page 324 of the 6.0 spec.