<div dir="ltr"><div>I have reviewed this while reviewing: <br><h2>r212516 - [OPENMP] Parsing and sema analysis for 'omp parallel sections' directive.</h2><span><table cellpadding="0">
<tbody><tr><td style="background-color:rgb(221,221,221);color:rgb(102,102,102)"><br></td><td style="background-color:rgb(221,221,221);color:rgb(102,102,102)"><br></td></tr></tbody></table></span><br>
</div>All the code is a similar pattern and looks good.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 26, 2014 at 4:21 AM, Alexey Bataev <span dir="ltr"><<a href="mailto:a.bataev@hotmail.com" target="_blank">a.bataev@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: abataev<br>
Date: Thu Jun 26 03:21:58 2014<br>
New Revision: 211767<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=211767&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=211767&view=rev</a><br>
Log:<br>
[OPENMP] Initial parsing and sema analysis for 'section' directive.<br>
<br>
Modified:<br>
    cfe/trunk/include/clang-c/Index.h<br>
    cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h<br>
    cfe/trunk/include/clang/AST/RecursiveASTVisitor.h<br>
    cfe/trunk/include/clang/AST/StmtOpenMP.h<br>
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
    cfe/trunk/include/clang/Basic/OpenMPKinds.def<br>
    cfe/trunk/include/clang/Basic/StmtNodes.td<br>
    cfe/trunk/include/clang/Sema/Sema.h<br>
    cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br>
    cfe/trunk/lib/AST/Stmt.cpp<br>
    cfe/trunk/lib/AST/StmtPrinter.cpp<br>
    cfe/trunk/lib/AST/StmtProfile.cpp<br>
    cfe/trunk/lib/Basic/OpenMPKinds.cpp<br>
    cfe/trunk/lib/CodeGen/CGStmt.cpp<br>
    cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp<br>
    cfe/trunk/lib/CodeGen/CodeGenFunction.h<br>
    cfe/trunk/lib/Parse/ParseOpenMP.cpp<br>
    cfe/trunk/lib/Sema/SemaOpenMP.cpp<br>
    cfe/trunk/lib/Sema/TreeTransform.h<br>
    cfe/trunk/lib/Serialization/ASTReaderStmt.cpp<br>
    cfe/trunk/lib/Serialization/ASTWriterStmt.cpp<br>
    cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp<br>
    cfe/trunk/test/OpenMP/nesting_of_regions.cpp<br>
    cfe/trunk/test/OpenMP/sections_ast_print.cpp<br>
    cfe/trunk/test/OpenMP/sections_misc_messages.c<br>
    cfe/trunk/tools/libclang/CIndex.cpp<br>
    cfe/trunk/tools/libclang/CXCursor.cpp<br>
<br>
Modified: cfe/trunk/include/clang-c/Index.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang-c/Index.h (original)<br>
+++ cfe/trunk/include/clang-c/Index.h Thu Jun 26 03:21:58 2014<br>
@@ -2147,7 +2147,11 @@ enum CXCursorKind {<br>
    */<br>
   CXCursor_OMPSectionsDirective          = 235,<br>
<br>
-  CXCursor_LastStmt                      = CXCursor_OMPSectionsDirective,<br>
+  /** \brief OpenMP section directive.<br>
+   */<br>
+  CXCursor_OMPSectionDirective           = 236,<br>
+<br>
+  CXCursor_LastStmt                      = CXCursor_OMPSectionDirective,<br>
<br>
   /**<br>
    * \brief Cursor that represents the translation unit itself.<br>
<br>
Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)<br>
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Thu Jun 26 03:21:58 2014<br>
@@ -2300,6 +2300,11 @@ DEF_TRAVERSE_STMT(OMPSectionsDirective,<br>
     return false;<br>
 })<br>
<br>
+DEF_TRAVERSE_STMT(OMPSectionDirective, {<br>
+  if (!TraverseOMPExecutableDirective(S))<br>
+    return false;<br>
+})<br>
+<br>
 // OpenMP clauses.<br>
 template <typename Derived><br>
 bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {<br>
<br>
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)<br>
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu Jun 26 03:21:58 2014<br>
@@ -2322,6 +2322,11 @@ DEF_TRAVERSE_STMT(OMPSectionsDirective,<br>
     return false;<br>
 })<br>
<br>
+DEF_TRAVERSE_STMT(OMPSectionDirective, {<br>
+  if (!TraverseOMPExecutableDirective(S))<br>
+    return false;<br>
+})<br>
+<br>
 // OpenMP clauses.<br>
 template <typename Derived><br>
 bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {<br>
<br>
Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)<br>
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Thu Jun 26 03:21:58 2014<br>
@@ -423,6 +423,53 @@ public:<br>
   }<br>
 };<br>
<br>
+/// \brief This represents '#pragma omp section' directive.<br>
+///<br>
+/// \code<br>
+/// #pragma omp section<br>
+/// \endcode<br>
+///<br>
+class OMPSectionDirective : public OMPExecutableDirective {<br>
+  friend class ASTStmtReader;<br>
+  /// \brief Build directive with the given start and end location.<br>
+  ///<br>
+  /// \param StartLoc Starting location of the directive kind.<br>
+  /// \param EndLoc Ending location of the directive.<br>
+  ///<br>
+  OMPSectionDirective(SourceLocation StartLoc, SourceLocation EndLoc)<br>
+      : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,<br>
+                               StartLoc, EndLoc, 0, 1) {}<br>
+<br>
+  /// \brief Build an empty directive.<br>
+  ///<br>
+  explicit OMPSectionDirective()<br>
+      : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,<br>
+                               SourceLocation(), SourceLocation(), 0, 1) {}<br>
+<br>
+public:<br>
+  /// \brief Creates directive.<br>
+  ///<br>
+  /// \param C AST context.<br>
+  /// \param StartLoc Starting location of the directive kind.<br>
+  /// \param EndLoc Ending Location of the directive.<br>
+  /// \param AssociatedStmt Statement, associated with the directive.<br>
+  ///<br>
+  static OMPSectionDirective *Create(const ASTContext &C,<br>
+                                     SourceLocation StartLoc,<br>
+                                     SourceLocation EndLoc,<br>
+                                     Stmt *AssociatedStmt);<br>
+<br>
+  /// \brief Creates an empty directive.<br>
+  ///<br>
+  /// \param C AST context.<br>
+  ///<br>
+  static OMPSectionDirective *CreateEmpty(const ASTContext &C, EmptyShell);<br>
+<br>
+  static bool classof(const Stmt *T) {<br>
+    return T->getStmtClass() == OMPSectionDirectiveClass;<br>
+  }<br>
+};<br>
+<br>
 } // end namespace clang<br>
<br>
 #endif<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jun 26 03:21:58 2014<br>
@@ -7115,6 +7115,11 @@ def err_omp_prohibited_region_simd : Err<br>
   "OpenMP constructs may not be nested inside a simd region">;<br>
 def err_omp_sections_not_compound_stmt : Error<<br>
   "the statement for '#pragma omp sections' must be a compound statement">;<br>
+def err_omp_orphaned_section_directive : Error<<br>
+  "%select{orphaned 'omp section' directives are prohibited, it|'omp section' directive}0"<br>
+  " must be closely nested to a sections region%select{|, not a %1 region}0">;<br>
+def err_omp_sections_substmt_not_section : Error<<br>
+  "statement in 'omp sections' directive must be enclosed into a section region">;<br>
 } // end of OpenMP category<br>
<br>
 let CategoryName = "Related Result Type Issue" in {<br>
<br>
Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)<br>
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Thu Jun 26 03:21:58 2014<br>
@@ -47,6 +47,7 @@ OPENMP_DIRECTIVE(task)<br>
 OPENMP_DIRECTIVE(simd)<br>
 OPENMP_DIRECTIVE(for)<br>
 OPENMP_DIRECTIVE(sections)<br>
+OPENMP_DIRECTIVE(section)<br>
<br>
 // OpenMP clauses.<br>
 OPENMP_CLAUSE(if, OMPIfClause)<br>
<br>
Modified: cfe/trunk/include/clang/Basic/StmtNodes.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/StmtNodes.td?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/StmtNodes.td?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Basic/StmtNodes.td (original)<br>
+++ cfe/trunk/include/clang/Basic/StmtNodes.td Thu Jun 26 03:21:58 2014<br>
@@ -181,3 +181,4 @@ def OMPParallelDirective : DStmt<OMPExec<br>
 def OMPSimdDirective : DStmt<OMPExecutableDirective>;<br>
 def OMPForDirective : DStmt<OMPExecutableDirective>;<br>
 def OMPSectionsDirective : DStmt<OMPExecutableDirective>;<br>
+def OMPSectionDirective : DStmt<OMPExecutableDirective>;<br>
<br>
Modified: cfe/trunk/include/clang/Sema/Sema.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Sema/Sema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jun 26 03:21:58 2014<br>
@@ -7327,6 +7327,10 @@ public:<br>
   StmtResult ActOnOpenMPSectionsDirective(ArrayRef<OMPClause *> Clauses,<br>
                                           Stmt *AStmt, SourceLocation StartLoc,<br>
                                           SourceLocation EndLoc);<br>
+  /// \brief Called on well-formed '\#pragma omp section' after parsing of the<br>
+  /// associated statement.<br>
+  StmtResult ActOnOpenMPSectionDirective(Stmt *AStmt, SourceLocation StartLoc,<br>
+                                         SourceLocation EndLoc);<br>
<br>
   OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,<br>
                                          Expr *Expr,<br>
<br>
Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)<br>
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Thu Jun 26 03:21:58 2014<br>
@@ -1343,6 +1343,7 @@ namespace clang {<br>
       STMT_OMP_SIMD_DIRECTIVE,<br>
       STMT_OMP_FOR_DIRECTIVE,<br>
       STMT_OMP_SECTIONS_DIRECTIVE,<br>
+      STMT_OMP_SECTION_DIRECTIVE,<br>
<br>
       // ARC<br>
       EXPR_OBJC_BRIDGED_CAST,     // ObjCBridgedCastExpr<br>
<br>
Modified: cfe/trunk/lib/AST/Stmt.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/AST/Stmt.cpp (original)<br>
+++ cfe/trunk/lib/AST/Stmt.cpp Thu Jun 26 03:21:58 2014<br>
@@ -1410,3 +1410,23 @@ OMPSectionsDirective *OMPSectionsDirecti<br>
   return new (Mem) OMPSectionsDirective(NumClauses);<br>
 }<br>
<br>
+OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C,<br>
+                                                 SourceLocation StartLoc,<br>
+                                                 SourceLocation EndLoc,<br>
+                                                 Stmt *AssociatedStmt) {<br>
+  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSectionsDirective),<br>
+                                           llvm::alignOf<Stmt *>());<br>
+  void *Mem = C.Allocate(Size + sizeof(Stmt *));<br>
+  OMPSectionDirective *Dir = new (Mem) OMPSectionDirective(StartLoc, EndLoc);<br>
+  Dir->setAssociatedStmt(AssociatedStmt);<br>
+  return Dir;<br>
+}<br>
+<br>
+OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,<br>
+                                                      EmptyShell) {<br>
+  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSectionDirective),<br>
+                                           llvm::alignOf<Stmt *>());<br>
+  void *Mem = C.Allocate(Size + sizeof(Stmt *));<br>
+  return new (Mem) OMPSectionDirective();<br>
+}<br>
+<br>
<br>
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)<br>
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Jun 26 03:21:58 2014<br>
@@ -792,6 +792,11 @@ void StmtPrinter::VisitOMPSectionsDirect<br>
   PrintOMPExecutableDirective(Node);<br>
 }<br>
<br>
+void StmtPrinter::VisitOMPSectionDirective(OMPSectionDirective *Node) {<br>
+  Indent() << "#pragma omp section";<br>
+  PrintOMPExecutableDirective(Node);<br>
+}<br>
+<br>
 //===----------------------------------------------------------------------===//<br>
 //  Expr printing methods.<br>
 //===----------------------------------------------------------------------===//<br>
<br>
Modified: cfe/trunk/lib/AST/StmtProfile.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)<br>
+++ cfe/trunk/lib/AST/StmtProfile.cpp Thu Jun 26 03:21:58 2014<br>
@@ -364,6 +364,10 @@ void StmtProfiler::VisitOMPSectionsDirec<br>
   VisitOMPExecutableDirective(S);<br>
 }<br>
<br>
+void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {<br>
+  VisitOMPExecutableDirective(S);<br>
+}<br>
+<br>
 void StmtProfiler::VisitExpr(const Expr *S) {<br>
   VisitStmt(S);<br>
 }<br>
<br>
Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)<br>
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Thu Jun 26 03:21:58 2014<br>
@@ -204,6 +204,7 @@ bool clang::isAllowedClauseForDirective(<br>
   case OMPD_unknown:<br>
   case OMPD_threadprivate:<br>
   case OMPD_task:<br>
+  case OMPD_section:<br>
     break;<br>
   }<br>
   return false;<br>
@@ -214,8 +215,8 @@ bool clang::isOpenMPLoopDirective(OpenMP<br>
 }<br>
<br>
 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {<br>
-  return DKind == OMPD_for ||<br>
-         DKind == OMPD_sections; // TODO add next directives.<br>
+  return DKind == OMPD_for || DKind == OMPD_sections ||<br>
+         DKind == OMPD_section; // TODO add next directives.<br>
 }<br>
<br>
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jun 26 03:21:58 2014<br>
@@ -185,6 +185,9 @@ void CodeGenFunction::EmitStmt(const Stm<br>
   case Stmt::OMPSectionsDirectiveClass:<br>
     EmitOMPSectionsDirective(cast<OMPSectionsDirective>(*S));<br>
     break;<br>
+  case Stmt::OMPSectionDirectiveClass:<br>
+    EmitOMPSectionDirective(cast<OMPSectionDirective>(*S));<br>
+    break;<br>
   }<br>
 }<br>
<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Jun 26 03:21:58 2014<br>
@@ -83,3 +83,7 @@ void CodeGenFunction::EmitOMPSectionsDir<br>
   llvm_unreachable("CodeGen for 'omp sections' is not supported yet.");<br>
 }<br>
<br>
+void CodeGenFunction::EmitOMPSectionDirective(const OMPSectionDirective &) {<br>
+  llvm_unreachable("CodeGen for 'omp section' is not supported yet.");<br>
+}<br>
+<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Jun 26 03:21:58 2014<br>
@@ -1904,6 +1904,7 @@ public:<br>
   void EmitOMPSimdDirective(const OMPSimdDirective &S);<br>
   void EmitOMPForDirective(const OMPForDirective &S);<br>
   void EmitOMPSectionsDirective(const OMPSectionsDirective &S);<br>
+  void EmitOMPSectionDirective(const OMPSectionDirective &S);<br>
<br>
   //===--------------------------------------------------------------------===//<br>
   //                         LValue Expression Emission<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Thu Jun 26 03:21:58 2014<br>
@@ -64,6 +64,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpen<br>
   case OMPD_task:<br>
   case OMPD_for:<br>
   case OMPD_sections:<br>
+  case OMPD_section:<br>
     Diag(Tok, diag::err_omp_unexpected_directive)<br>
         << getOpenMPDirectiveName(DKind);<br>
     break;<br>
@@ -79,8 +80,8 @@ Parser::DeclGroupPtrTy Parser::ParseOpen<br>
 ///         annot_pragma_openmp_end<br>
 ///<br>
 ///       executable-directive:<br>
-///         annot_pragma_openmp 'parallel'|'simd'|'for'|'sections'  {clause}<br>
-///         annot_pragma_openmp_end<br>
+///         annot_pragma_openmp 'parallel'|'simd'|'for'|'sections'|'section'<br>
+///         {clause} annot_pragma_openmp_end<br>
 ///<br>
 StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() {<br>
   assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");<br>
@@ -119,7 +120,8 @@ StmtResult Parser::ParseOpenMPDeclarativ<br>
   case OMPD_parallel:<br>
   case OMPD_simd:<br>
   case OMPD_for:<br>
-  case OMPD_sections: {<br>
+  case OMPD_sections:<br>
+  case OMPD_section: {<br>
     ConsumeToken();<br>
<br>
     if (isOpenMPLoopDirective(DKind))<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jun 26 03:21:58 2014<br>
@@ -917,6 +917,13 @@ void Sema::ActOnOpenMPRegionStart(OpenMP<br>
     ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP, Params);<br>
     break;<br>
   }<br>
+  case OMPD_section: {<br>
+    Sema::CapturedParamNameType Params[] = {<br>
+        std::make_pair(StringRef(), QualType()) // __context with shared vars<br>
+    };<br>
+    ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP, Params);<br>
+    break;<br>
+  }<br>
   case OMPD_threadprivate:<br>
   case OMPD_task:<br>
     llvm_unreachable("OpenMP Directive is not allowed");<br>
@@ -939,6 +946,19 @@ bool CheckNestingOfRegions(Sema &SemaRef<br>
       SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_simd);<br>
       return true;<br>
     }<br>
+    if (CurrentRegion == OMPD_section) {<br>
+      // OpenMP [2.7.2, sections Construct, Restrictions]<br>
+      // Orphaned section directives are prohibited. That is, the section<br>
+      // directives must appear within the sections construct and must not be<br>
+      // encountered elsewhere in the sections region.<br>
+      if (ParentRegion != OMPD_sections) {<br>
+        SemaRef.Diag(StartLoc, diag::err_omp_orphaned_section_directive)<br>
+            << (ParentRegion != OMPD_unknown)<br>
+            << getOpenMPDirectiveName(ParentRegion);<br>
+        return true;<br>
+      }<br>
+      return false;<br>
+    }<br>
     if (isOpenMPWorksharingDirective(CurrentRegion) &&<br>
         !isOpenMPParallelDirective(CurrentRegion) &&<br>
         !isOpenMPSimdDirective(CurrentRegion)) {<br>
@@ -1008,6 +1028,11 @@ StmtResult Sema::ActOnOpenMPExecutableDi<br>
     Res = ActOnOpenMPSectionsDirective(ClausesWithImplicit, AStmt, StartLoc,<br>
                                        EndLoc);<br>
     break;<br>
+  case OMPD_section:<br>
+    assert(ClausesWithImplicit.empty() &&<br>
+           "No clauses is allowed for 'omp section' directive");<br>
+    Res = ActOnOpenMPSectionDirective(AStmt, StartLoc, EndLoc);<br>
+    break;<br>
   case OMPD_threadprivate:<br>
   case OMPD_task:<br>
     llvm_unreachable("OpenMP Directive is not allowed");<br>
@@ -1592,7 +1617,15 @@ StmtResult Sema::ActOnOpenMPSectionsDire<br>
       return StmtError();<br>
     // All associated statements must be '#pragma omp section' except for<br>
     // the first one.<br>
-    // TODO<br>
+    for (++S; S; ++S) {<br>
+      auto SectionStmt = *S;<br>
+      if (!SectionStmt || !isa<OMPSectionDirective>(SectionStmt)) {<br>
+        if (SectionStmt)<br>
+          Diag(SectionStmt->getLocStart(),<br>
+               diag::err_omp_sections_substmt_not_section);<br>
+        return StmtError();<br>
+      }<br>
+    }<br>
   } else {<br>
     Diag(AStmt->getLocStart(), diag::err_omp_sections_not_compound_stmt);<br>
     return StmtError();<br>
@@ -1604,6 +1637,16 @@ StmtResult Sema::ActOnOpenMPSectionsDire<br>
                                       AStmt);<br>
 }<br>
<br>
+StmtResult Sema::ActOnOpenMPSectionDirective(Stmt *AStmt,<br>
+                                             SourceLocation StartLoc,<br>
+                                             SourceLocation EndLoc) {<br>
+  assert(AStmt && isa<CapturedStmt>(AStmt) && "Captured statement expected");<br>
+<br>
+  getCurFunction()->setHasBranchProtectedScope();<br>
+<br>
+  return OMPSectionDirective::Create(Context, StartLoc, EndLoc, AStmt);<br>
+}<br>
+<br>
 OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,<br>
                                              SourceLocation StartLoc,<br>
                                              SourceLocation LParenLoc,<br>
<br>
Modified: cfe/trunk/lib/Sema/TreeTransform.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Sema/TreeTransform.h (original)<br>
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Jun 26 03:21:58 2014<br>
@@ -6439,6 +6439,16 @@ TreeTransform<Derived>::TransformOMPSect<br>
   return Res;<br>
 }<br>
<br>
+template <typename Derived><br>
+StmtResult<br>
+TreeTransform<Derived>::TransformOMPSectionDirective(OMPSectionDirective *D) {<br>
+  DeclarationNameInfo DirName;<br>
+  getDerived().getSema().StartOpenMPDSABlock(OMPD_section, DirName, nullptr);<br>
+  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);<br>
+  getDerived().getSema().EndOpenMPDSABlock(Res.get());<br>
+  return Res;<br>
+}<br>
+<br>
 //===----------------------------------------------------------------------===//<br>
 // OpenMP clause transformation<br>
 //===----------------------------------------------------------------------===//<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Thu Jun 26 03:21:58 2014<br>
@@ -1913,6 +1913,11 @@ void ASTStmtReader::VisitOMPSectionsDire<br>
   VisitOMPExecutableDirective(D);<br>
 }<br>
<br>
+void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {<br>
+  VisitStmt(D);<br>
+  VisitOMPExecutableDirective(D);<br>
+}<br>
+<br>
 //===----------------------------------------------------------------------===//<br>
 // ASTReader Implementation<br>
 //===----------------------------------------------------------------------===//<br>
@@ -2413,6 +2418,10 @@ Stmt *ASTReader::ReadStmtFromStream(Modu<br>
           Context, Record[ASTStmtReader::NumStmtFields], Empty);<br>
       break;<br>
<br>
+    case STMT_OMP_SECTION_DIRECTIVE:<br>
+      S = OMPSectionDirective::CreateEmpty(Context, Empty);<br>
+      break;<br>
+<br>
     case EXPR_CXX_OPERATOR_CALL:<br>
       S = new (Context) CXXOperatorCallExpr(Context, Empty);<br>
       break;<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Thu Jun 26 03:21:58 2014<br>
@@ -1825,6 +1825,12 @@ void ASTStmtWriter::VisitOMPSectionsDire<br>
   Code = serialization::STMT_OMP_SECTIONS_DIRECTIVE;<br>
 }<br>
<br>
+void ASTStmtWriter::VisitOMPSectionDirective(OMPSectionDirective *D) {<br>
+  VisitStmt(D);<br>
+  VisitOMPExecutableDirective(D);<br>
+  Code = serialization::STMT_OMP_SECTION_DIRECTIVE;<br>
+}<br>
+<br>
 //===----------------------------------------------------------------------===//<br>
 // ASTWriter Implementation<br>
 //===----------------------------------------------------------------------===//<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Thu Jun 26 03:21:58 2014<br>
@@ -734,6 +734,7 @@ void ExprEngine::Visit(const Stmt *S, Ex<br>
     case Stmt::OMPSimdDirectiveClass:<br>
     case Stmt::OMPForDirectiveClass:<br>
     case Stmt::OMPSectionsDirectiveClass:<br>
+    case Stmt::OMPSectionDirectiveClass:<br>
       llvm_unreachable("Stmt should not be in analyzer evaluation loop");<br>
<br>
     case Stmt::ObjCSubscriptRefExprClass:<br>
<br>
Modified: cfe/trunk/test/OpenMP/nesting_of_regions.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nesting_of_regions.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nesting_of_regions.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/OpenMP/nesting_of_regions.cpp (original)<br>
+++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp Thu Jun 26 03:21:58 2014<br>
@@ -6,29 +6,39 @@ template <class T><br>
 void foo() {<br>
 #pragma omp parallel<br>
 #pragma omp for<br>
-  for (int i = 0; i < 10; ++i);<br>
+  for (int i = 0; i < 10; ++i)<br>
+    ;<br>
 #pragma omp parallel<br>
 #pragma omp simd<br>
-  for (int i = 0; i < 10; ++i);<br>
+  for (int i = 0; i < 10; ++i)<br>
+    ;<br>
 #pragma omp parallel<br>
 #pragma omp sections<br>
   {<br>
     bar();<br>
   }<br>
+#pragma omp parallel<br>
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel region}}<br>
+  {<br>
+    bar();<br>
+  }<br>
 #pragma omp simd<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp simd<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp simd<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp simd<br>
   for (int i = 0; i < 10; ++i) {<br>
@@ -37,20 +47,30 @@ void foo() {<br>
       bar();<br>
     }<br>
   }<br>
+#pragma omp simd<br>
+  for (int i = 0; i < 10; ++i) {<br>
+#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}<br>
+    {<br>
+      bar();<br>
+    }<br>
+  }<br>
 #pragma omp for<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp for // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp for<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp simd<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp for<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp parallel<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp for<br>
   for (int i = 0; i < 10; ++i) {<br>
@@ -59,20 +79,30 @@ void foo() {<br>
       bar();<br>
     }<br>
   }<br>
+#pragma omp for<br>
+  for (int i = 0; i < 10; ++i) {<br>
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a for region}}<br>
+    {<br>
+      bar();<br>
+    }<br>
+  }<br>
 #pragma omp sections<br>
   {<br>
 #pragma omp for // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp sections<br>
   {<br>
 #pragma omp simd<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp sections<br>
   {<br>
 #pragma omp parallel<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp sections<br>
   {<br>
@@ -81,34 +111,55 @@ void foo() {<br>
       bar();<br>
     }<br>
   }<br>
+#pragma omp sections<br>
+  {<br>
+#pragma omp section<br>
+    {<br>
+      bar();<br>
+    }<br>
+  }<br>
+#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}<br>
+  {<br>
+    bar();<br>
+  }<br>
 }<br>
<br>
 void foo() {<br>
 #pragma omp parallel<br>
 #pragma omp for<br>
-  for (int i = 0; i < 10; ++i);<br>
+  for (int i = 0; i < 10; ++i)<br>
+    ;<br>
 #pragma omp parallel<br>
 #pragma omp simd<br>
-  for (int i = 0; i < 10; ++i);<br>
+  for (int i = 0; i < 10; ++i)<br>
+    ;<br>
 #pragma omp parallel<br>
 #pragma omp sections<br>
   {<br>
     bar();<br>
   }<br>
+#pragma omp parallel<br>
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel region}}<br>
+  {<br>
+    bar();<br>
+  }<br>
 #pragma omp simd<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp simd<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp simd<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp simd<br>
   for (int i = 0; i < 10; ++i) {<br>
@@ -117,20 +168,30 @@ void foo() {<br>
       bar();<br>
     }<br>
   }<br>
+#pragma omp simd<br>
+  for (int i = 0; i < 10; ++i) {<br>
+#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}<br>
+    {<br>
+      bar();<br>
+    }<br>
+  }<br>
 #pragma omp for<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp for // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp for<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp simd<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp for<br>
   for (int i = 0; i < 10; ++i) {<br>
 #pragma omp parallel<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp for<br>
   for (int i = 0; i < 10; ++i) {<br>
@@ -139,20 +200,30 @@ void foo() {<br>
       bar();<br>
     }<br>
   }<br>
+#pragma omp for<br>
+  for (int i = 0; i < 10; ++i) {<br>
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a for region}}<br>
+    {<br>
+      bar();<br>
+    }<br>
+  }<br>
 #pragma omp sections<br>
   {<br>
 #pragma omp for // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp sections<br>
   {<br>
 #pragma omp simd<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp sections<br>
   {<br>
 #pragma omp parallel<br>
-  for (int i = 0; i < 10; ++i);<br>
+    for (int i = 0; i < 10; ++i)<br>
+      ;<br>
   }<br>
 #pragma omp sections<br>
   {<br>
@@ -161,6 +232,17 @@ void foo() {<br>
       bar();<br>
     }<br>
   }<br>
+#pragma omp sections<br>
+  {<br>
+#pragma omp section<br>
+    {<br>
+      bar();<br>
+    }<br>
+  }<br>
+#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}<br>
+  {<br>
+    bar();<br>
+  }<br>
   return foo<int>();<br>
 }<br>
<br>
<br>
Modified: cfe/trunk/test/OpenMP/sections_ast_print.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/sections_ast_print.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/sections_ast_print.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/OpenMP/sections_ast_print.cpp (original)<br>
+++ cfe/trunk/test/OpenMP/sections_ast_print.cpp Thu Jun 26 03:21:58 2014<br>
@@ -14,9 +14,9 @@ T tmain(T argc) {<br>
   static T a;<br>
 // CHECK: static T a;<br>
 #pragma omp parallel<br>
-#pragma omp sections private(argc, b), firstprivate(c, d), lastprivate(d, f) reduction (-: g) nowait<br>
+#pragma omp sections private(argc, b), firstprivate(c, d), lastprivate(d, f) reduction(- : g) nowait<br>
   {<br>
-            foo();<br>
+    foo();<br>
   }<br>
   // CHECK-NEXT: #pragma omp parallel<br>
   // CHECK-NEXT: #pragma omp sections private(argc,b) firstprivate(c,d) lastprivate(d,f) reduction(-: g) nowait<br>
@@ -31,13 +31,19 @@ int main(int argc, char **argv) {<br>
   static int a;<br>
 // CHECK: static int a;<br>
 #pragma omp parallel<br>
-#pragma omp sections private(argc, b), firstprivate(argv, c), lastprivate(d, f) reduction(+:g) nowait<br>
+#pragma omp sections private(argc, b), firstprivate(argv, c), lastprivate(d, f) reduction(+ : g) nowait<br>
   {<br>
-      foo();<br>
+#pragma omp section<br>
+    foo();<br>
+#pragma omp section<br>
+    foo();<br>
   }<br>
   // CHECK-NEXT: #pragma omp parallel<br>
   // CHECK-NEXT: #pragma omp sections private(argc,b) firstprivate(argv,c) lastprivate(d,f) reduction(+: g) nowait<br>
   // CHECK-NEXT: {<br>
+  // CHECK-NEXT: #pragma omp section<br>
+  // CHECK-NEXT: foo();<br>
+  // CHECK-NEXT: #pragma omp section<br>
   // CHECK-NEXT: foo();<br>
   // CHECK-NEXT: }<br>
   return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));<br>
<br>
Modified: cfe/trunk/test/OpenMP/sections_misc_messages.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/sections_misc_messages.c?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/sections_misc_messages.c?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/OpenMP/sections_misc_messages.c (original)<br>
+++ cfe/trunk/test/OpenMP/sections_misc_messages.c Thu Jun 26 03:21:58 2014<br>
@@ -18,6 +18,13 @@ void test_no_clause() {<br>
 // expected-error@+2 {{the statement for '#pragma omp sections' must be a compound statement}}<br>
 #pragma omp sections<br>
   ++i;<br>
+<br>
+#pragma omp sections<br>
+  {<br>
+    foo();<br>
+    foo(); // expected-error {{statement in 'omp sections' directive must be enclosed into a section region}}<br>
+  }<br>
+<br>
 }<br>
<br>
 void test_branch_protected_scope() {<br>
@@ -40,12 +47,24 @@ L1:<br>
     L2:<br>
       x[i]++;<br>
     }<br>
+#pragma omp section<br>
+    if (i == 5)<br>
+      goto L1; // expected-error {{use of undeclared label 'L1'}}<br>
+    else if (i == 6)<br>
+      return; // expected-error {{cannot return from OpenMP region}}<br>
+    else if (i == 7)<br>
+      goto L3;<br>
+    else if (i == 8) {<br>
+    L3:<br>
+      x[i]++;<br>
+    }<br>
   }<br>
<br>
   if (x[0] == 0)<br>
     goto L2; // expected-error {{use of undeclared label 'L2'}}<br>
   else if (x[1] == 1)<br>
     goto L1;<br>
+  goto L3; // expected-error {{use of undeclared label 'L3'}}<br>
 }<br>
<br>
 void test_invalid_clause() {<br>
@@ -55,6 +74,9 @@ void test_invalid_clause() {<br>
 #pragma omp sections foo bar<br>
   {<br>
     foo();<br>
+// expected-error@+1 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp section'}}<br>
+#pragma omp section nowait<br>
+    ;<br>
   }<br>
 }<br>
<br>
<br>
Modified: cfe/trunk/tools/libclang/CIndex.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/tools/libclang/CIndex.cpp (original)<br>
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Jun 26 03:21:58 2014<br>
@@ -1853,6 +1853,7 @@ public:<br>
   void VisitOMPSimdDirective(const OMPSimdDirective *D);<br>
   void VisitOMPForDirective(const OMPForDirective *D);<br>
   void VisitOMPSectionsDirective(const OMPSectionsDirective *D);<br>
+  void VisitOMPSectionDirective(const OMPSectionDirective *D);<br>
<br>
 private:<br>
   void AddDeclarationNameInfo(const Stmt *S);<br>
@@ -2292,6 +2293,10 @@ void EnqueueVisitor::VisitOMPSectionsDir<br>
   VisitOMPExecutableDirective(D);<br>
 }<br>
<br>
+void EnqueueVisitor::VisitOMPSectionDirective(const OMPSectionDirective *D) {<br>
+  VisitOMPExecutableDirective(D);<br>
+}<br>
+<br>
 void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, const Stmt *S) {<br>
   EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S);<br>
 }<br>
@@ -3972,6 +3977,8 @@ CXString clang_getCursorKindSpelling(enu<br>
     return cxstring::createRef("OMPForDirective");<br>
   case CXCursor_OMPSectionsDirective:<br>
     return cxstring::createRef("OMPSectionsDirective");<br>
+  case CXCursor_OMPSectionDirective:<br>
+    return cxstring::createRef("OMPSectionDirective");<br>
   }<br>
<br>
   llvm_unreachable("Unhandled CXCursorKind");<br>
<br>
Modified: cfe/trunk/tools/libclang/CXCursor.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=211767&r1=211766&r2=211767&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=211767&r1=211766&r2=211767&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)<br>
+++ cfe/trunk/tools/libclang/CXCursor.cpp Thu Jun 26 03:21:58 2014<br>
@@ -525,6 +525,9 @@ CXCursor cxcursor::MakeCXCursor(const St<br>
   case Stmt::OMPSectionsDirectiveClass:<br>
     K = CXCursor_OMPSectionsDirective;<br>
     break;<br>
+  case Stmt::OMPSectionDirectiveClass:<br>
+    K = CXCursor_OMPSectionDirective;<br>
+    break;<br>
   }<br>
<br>
   CXCursor C = { K, 0, { Parent, S, TU } };<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>