diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 6bbf3476e740..61f4dade50c5 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -3589,6 +3589,8 @@ StmtResult Sema::HandleSimpleCilkForStmt(SourceLocation CilkForLoc, StrideIsNegative = StrideWithSign.second; Stride = StrideWithSign.first; } + if (!StrideIsUnit && !Stride) + return StmtEmpty(); // Determine the type of comparison. // diff --git a/clang/test/Cilk/cilkfor-complicated-stride.c b/clang/test/Cilk/cilkfor-complicated-stride.c new file mode 100644 index 000000000000..180a364caaef --- /dev/null +++ b/clang/test/Cilk/cilkfor-complicated-stride.c @@ -0,0 +1,11 @@ +// Check that Clang properly handles cilk_for loops with complicated stride +// calculations. +// +// RUN: %clang_cc1 %s -fopencilk -verify -fsyntax-only +// expected-no-diagnostics + +void test(char *data, unsigned long size) +{ + _Cilk_for (unsigned long i = 0; i < size; i = i + (1 << 21)) + ((char*) data)[i] = 0; +}