507 changes: 491 additions & 16 deletions clang/lib/Sema/SemaOpenMP.cpp

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions clang/lib/Sema/SemaStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2417,6 +2417,9 @@ Sema::ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope) {
// C99 6.8.6.3p1: A break shall appear only in or as a switch/loop body.
return StmtError(Diag(BreakLoc, diag::err_break_not_in_loop_or_switch));
}
if (S->isOpenMPLoopScope())
return StmtError(Diag(BreakLoc, diag::err_omp_loop_cannot_use_stmt)
<< "break");

return new (Context) BreakStmt(BreakLoc);
}
Expand Down Expand Up @@ -3188,6 +3191,9 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
!getSourceManager().isInSystemHeader(TryLoc))
Diag(TryLoc, diag::err_exceptions_disabled) << "try";

if (getCurScope() && getCurScope()->isOpenMPSimdDirectiveScope())
Diag(TryLoc, diag::err_omp_simd_region_cannot_use_stmt) << "try";

const unsigned NumHandlers = Handlers.size();
assert(NumHandlers > 0 &&
"The parser shouldn't call this if there are no handlers.");
Expand Down
574 changes: 574 additions & 0 deletions clang/test/OpenMP/simd_loop_messages.cpp

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions clang/test/OpenMP/simd_misc_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,18 @@ void test_firstprivate()
for (i = 0; i < 16; ++i) ;
}

void test_loop_messages()
{
float a[100], b[100], c[100];
// expected-error@+2 {{variable must be of integer or pointer type}}
#pragma omp simd
for (float fi = 0; fi < 10.0; fi++) {
c[(int)fi] = a[(int)fi] + b[(int)fi];
}
// expected-error@+2 {{variable must be of integer or pointer type}}
#pragma omp simd
for (double fi = 0; fi < 10.0; fi++) {
c[(int)fi] = a[(int)fi] + b[(int)fi];
}
}