<div dir="ltr"><br><div class="gmail_extra">just correct a typo, please read the below message. </div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 18, 2015 at 1:01 PM, xiaohui chen <span dir="ltr"><<a href="mailto:xchen198812@gmail.com" target="_blank">xchen198812@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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" target="_blank">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 block.</div><div><br></div><div><br></div></div>
</blockquote></div><br></div></div>