<div dir="ltr">Hi, <div>I am using clang version 3.6.0 (trunk 224915).</div><div><br></div><div>Clang can not parse the following valid OpenMP code:</div><div><br></div><div><div> 1 #include<omp.h></div><div>  2 void main()</div><div>  3 {</div><div>  4 Â  Â  Â  Â  int i;</div><div>  5 Â  Â  Â  Â  #pragma omp parallel</div><div>  6 Â  Â  Â  Â  #pragma omp sections</div><div>  7 Â  Â  Â  Â  {</div><div>  8 Â  Â  Â  Â  Â  Â  Â  Â  i++;</div><div>  9 Â  Â  Â  Â  Â  Â  Â  Â  i++;</div><div> 10 Â  Â  Â  Â  Â  Â  Â  Â  #pragma omp section</div><div> 11 Â  Â  Â  Â  Â  Â  Â  Â  i++;</div><div> 12 Â  Â  Â  Â  }</div><div> 13 }</div></div><div><br></div><div>The bug comes from line 8 and 9.</div><div><br></div><div>In OpenMP documentation (<a href="http://www.openmp.org/mp-documents/OpenMP4.0.0.pdf">http://www.openmp.org/mp-documents/OpenMP4.0.0.pdf</a>) page 62,</div><div>it says"Each structured block in the sections construct is preceded by a section directive </div><div>except possibly the first block, for which a preceding section directive is optional." .</div><div><br></div><div>it means that the section directive is optional for the first block, but not the first statement.</div><div><br></div><div>in function  StmtResult Sema::ActOnOpenMPSectionsDirective, </div><div><br></div><div><div>3021 StmtResult Sema::ActOnOpenMPSectionsDirective(ArrayRef<OMPClause *> Clauses,</div><div>3022 Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Stmt *AStmt,</div><div>3023 Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  SourceLocation StartLoc,</div><div>3024 Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  SourceLocation EndLoc) {</div><div>3025 Â  assert(AStmt && isa<CapturedStmt>(AStmt) && "Captured statement expected");</div><div>3026 Â  auto BaseStmt = AStmt;</div><div>3027 Â  while (CapturedStmt *CS = dyn_cast_or_null<CapturedStmt>(BaseStmt))</div><div>3028 Â  Â  BaseStmt = CS->getCapturedStmt();</div><div>3029 Â  if (auto C = dyn_cast_or_null<CompoundStmt>(BaseStmt)) {</div><div>3030 Â  Â  auto S = C->children();</div><div>3031 Â  Â  if (!S)</div><div>3032 Â  Â  Â  return StmtError();</div><div>3033 Â  Â  // All associated statements must be '#pragma omp section' except for</div><div>3034 Â  Â  // the first one.</div><div>3035 Â  Â  for (++S; S; ++S) {</div><div>3036 Â  Â  Â  auto SectionStmt = *S;</div><div>3037 Â  Â  Â  if (!SectionStmt || !isa<OMPSectionDirective>(SectionStmt)) {</div><div>3038 Â  Â  Â  Â  if (SectionStmt)</div><div>3039 Â  Â  Â  Â  Â  Diag(SectionStmt->getLocStart(),</div><div>3040 Â  Â  Â  Â  Â  Â  Â  Â diag::err_omp_sections_substmt_not_section);</div><div>3041 Â  Â  Â  Â  return StmtError();</div><div>3042 Â  Â  Â  }</div><div>3043 Â  Â  }</div><div>3044 Â  } else {</div><div>3045 Â  Â  Diag(AStmt->getLocStart(), diag::err_omp_sections_not_compound_stmt);</div><div>3046 Â  Â  return StmtError();</div><div>3047 Â  }</div><div>3048 </div><div>3049 Â  getCurFunction()->setHasBranchProtectedScope();</div><div>3050 </div><div>3051 Â  return OMPSectionsDirective::Create(Context, StartLoc, EndLoc, Clauses,</div><div>3052 Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  AStmt);</div><div>3053 }</div></div><div><br></div><div>Notice from line 3035 to line 3042, it just checks the first statement not the first statement.</div><div><br></div><div><br></div></div>