Index: clang/lib/Parse/ParseOpenMP.cpp =================================================================== --- clang/lib/Parse/ParseOpenMP.cpp +++ clang/lib/Parse/ParseOpenMP.cpp @@ -2864,6 +2864,8 @@ EndLoc = Tok.getLocation(); // Consume final annot_pragma_openmp_end. ConsumeAnnotationToken(); + // Reset for parsing the associated statement. + ReadDirectiveWithinMetadirective = false; // OpenMP [2.13.8, ordered Construct, Syntax] // If the depend clause is specified, the ordered construct is a stand-alone Index: clang/test/OpenMP/metadirective_ast_print.c =================================================================== --- clang/test/OpenMP/metadirective_ast_print.c +++ clang/test/OpenMP/metadirective_ast_print.c @@ -47,6 +47,16 @@ : parallel) default(parallel for) for (int i = 0; i < 100; i++) ; + +// Test metadirective with nested OpenMP directive. + int array[16]; + #pragma omp metadirective when(user = {condition(1)} \ + : parallel for) + for (int i = 0; i < 16; i++) { + #pragma omp simd + for (int j = 0; j < 16; j++) + array[i] = i; + } } // CHECK: void bar(); @@ -69,5 +79,9 @@ // CHECK-NEXT: for (int i = 0; i < 100; i++) // CHECK: #pragma omp parallel // CHECK-NEXT: for (int i = 0; i < 100; i++) +// CHECK: #pragma omp parallel for +// CHECK-NEXT: for (int i = 0; i < 16; i++) { +// CHECK-NEXT: #pragma omp simd +// CHECK-NEXT: for (int j = 0; j < 16; j++) #endif