Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -2256,9 +2256,6 @@ OpenMPDirectiveKind CancelRegion, ArrayRef Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc) { StmtResult Res = StmtError(); - if (CheckNestingOfRegions(*this, DSAStack, Kind, DirName, CancelRegion, - StartLoc)) - return StmtError(); llvm::SmallVector ClausesWithImplicit; llvm::DenseMap VarsWithInheritedDSA; @@ -2541,6 +2538,10 @@ llvm_unreachable("Unknown OpenMP directive"); } + if (!Res.isInvalid() && CheckNestingOfRegions(*this, DSAStack, Kind, DirName, + CancelRegion, StartLoc)) + return StmtError(); + for (auto P : VarsWithInheritedDSA) { Diag(P.second->getExprLoc(), diag::err_omp_no_dsa_for_variable) << P.first << P.second->getSourceRange(); Index: test/OpenMP/cancel_messages.cpp =================================================================== --- test/OpenMP/cancel_messages.cpp +++ test/OpenMP/cancel_messages.cpp @@ -4,8 +4,16 @@ #pragma omp cancellation // expected-error {{expected an OpenMP directive}} #pragma omp cancel // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}} ; +#pragma omp parallel + { +#pragma omp cancel // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}} + } #pragma omp cancel parallel untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp cancel'}} #pragma omp cancel unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}} +#pragma omp parallel + { +#pragma omp cancel unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}} + } #pragma omp cancel sections( // expected-warning {{extra tokens at the end of '#pragma omp cancel' are ignored}} #pragma omp cancel for, ) // expected-warning {{extra tokens at the end of '#pragma omp cancel' are ignored}} #pragma omp cancel taskgroup() // expected-warning {{extra tokens at the end of '#pragma omp cancel' are ignored}} Index: test/OpenMP/cancellation_point_messages.cpp =================================================================== --- test/OpenMP/cancellation_point_messages.cpp +++ test/OpenMP/cancellation_point_messages.cpp @@ -4,8 +4,16 @@ #pragma omp cancellation // expected-error {{expected an OpenMP directive}} #pragma omp cancellation point // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}} ; +#pragma omp parallel + { +#pragma omp cancellation point // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}} + } #pragma omp cancellation point parallel untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp cancellation point'}} #pragma omp cancellation point unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}} +#pragma omp parallel + { +#pragma omp cancellation point unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}} + } #pragma omp cancellation point sections( // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}} #pragma omp cancellation point for, ) // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}} #pragma omp cancellation point taskgroup() // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}} Index: test/OpenMP/nesting_of_regions.cpp =================================================================== --- test/OpenMP/nesting_of_regions.cpp +++ test/OpenMP/nesting_of_regions.cpp @@ -12467,7 +12467,7 @@ // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}} // expected-note@+1 {{expected an expression statement}} { -#pragma omp target update // expected-error {{OpenMP constructs may not be nested inside an atomic region}} +#pragma omp target update to(a) // expected-error {{OpenMP constructs may not be nested inside an atomic region}} } #pragma omp atomic // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}} Index: test/OpenMP/task_messages.cpp =================================================================== --- test/OpenMP/task_messages.cpp +++ test/OpenMP/task_messages.cpp @@ -101,7 +101,8 @@ // expected-error@+2 {{reduction variable must be shared}} // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} #pragma omp for reduction(+ : r) - ++r; + for (int i = 0; i < 10; ++i) + ++r; // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}} #pragma omp task untied untied ++r; @@ -257,7 +258,8 @@ // expected-error@+2 {{reduction variable must be shared}} // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} #pragma omp for reduction(+ : r) - ++r; + for (int i = 0; i < 10; ++i) + ++r; // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}} #pragma omp task untied untied ++r;