This patch (to be applied on top of the metadirective patch series) addresses issues found in the C/C++ parsers when nested metadirectives are used. analyze_metadirective_body when encountering code like: #pragma omp metadirective when {set={...}: A) #pragma omp metadirective when (set={...}: B) would stop just before ': B' before it naively assumes that the '}' marks the end of the body associated with the first metadirective, when it needs to include the whole of the second metadirective plus its associated body. This is fixed by checking that the nesting level of parentheses is zero as well before stopping the gathering of tokens. The assert on the remaining tokens after parsing a clause can fail (resulting in an ICE) if there is a parse error in the directive or the body, since in that case not all tokens may be processed before parsing aborts early. The assert is therefore not enforced if any parse errors occur in the clause. I have also moved the handling of the metadirective pragma from c_parser_omp_construct to c_parser_pragma (and their C++ equivalents), since c_parser_omp_construct has some checks that do not apply to metadirectives. Kwok