summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-06-26 08:21:58 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-06-26 08:21:58 +0000
commit0eca5e96c1b22228c8efe6a99df123186bfb340b (patch)
tree3eda9832f1dff4a048c29baecbb63a641818fc94 /include
parenta7e2b09e84da88716b148b4042164e7b321aa13d (diff)
downloadclang-0eca5e96c1b22228c8efe6a99df123186bfb340b.tar.gz
clang-0eca5e96c1b22228c8efe6a99df123186bfb340b.tar.bz2
clang-0eca5e96c1b22228c8efe6a99df123186bfb340b.tar.xz
[OPENMP] Initial parsing and sema analysis for 'section' directive.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211767 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang-c/Index.h6
-rw-r--r--include/clang/AST/DataRecursiveASTVisitor.h5
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h5
-rw-r--r--include/clang/AST/StmtOpenMP.h47
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td5
-rw-r--r--include/clang/Basic/OpenMPKinds.def1
-rw-r--r--include/clang/Basic/StmtNodes.td1
-rw-r--r--include/clang/Sema/Sema.h4
-rw-r--r--include/clang/Serialization/ASTBitCodes.h1
9 files changed, 74 insertions, 1 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 567522e044..909e2dbfe2 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -2147,7 +2147,11 @@ enum CXCursorKind {
*/
CXCursor_OMPSectionsDirective = 235,
- CXCursor_LastStmt = CXCursor_OMPSectionsDirective,
+ /** \brief OpenMP section directive.
+ */
+ CXCursor_OMPSectionDirective = 236,
+
+ CXCursor_LastStmt = CXCursor_OMPSectionDirective,
/**
* \brief Cursor that represents the translation unit itself.
diff --git a/include/clang/AST/DataRecursiveASTVisitor.h b/include/clang/AST/DataRecursiveASTVisitor.h
index 9a27c3954a..536d372ec4 100644
--- a/include/clang/AST/DataRecursiveASTVisitor.h
+++ b/include/clang/AST/DataRecursiveASTVisitor.h
@@ -2300,6 +2300,11 @@ DEF_TRAVERSE_STMT(OMPSectionsDirective, {
return false;
})
+DEF_TRAVERSE_STMT(OMPSectionDirective, {
+ if (!TraverseOMPExecutableDirective(S))
+ return false;
+})
+
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index 9e9d4effd9..eae370e0b8 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -2322,6 +2322,11 @@ DEF_TRAVERSE_STMT(OMPSectionsDirective, {
return false;
})
+DEF_TRAVERSE_STMT(OMPSectionDirective, {
+ if (!TraverseOMPExecutableDirective(S))
+ return false;
+})
+
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
diff --git a/include/clang/AST/StmtOpenMP.h b/include/clang/AST/StmtOpenMP.h
index aca0274192..8b954f45e7 100644
--- a/include/clang/AST/StmtOpenMP.h
+++ b/include/clang/AST/StmtOpenMP.h
@@ -423,6 +423,53 @@ public:
}
};
+/// \brief This represents '#pragma omp section' directive.
+///
+/// \code
+/// #pragma omp section
+/// \endcode
+///
+class OMPSectionDirective : public OMPExecutableDirective {
+ friend class ASTStmtReader;
+ /// \brief Build directive with the given start and end location.
+ ///
+ /// \param StartLoc Starting location of the directive kind.
+ /// \param EndLoc Ending location of the directive.
+ ///
+ OMPSectionDirective(SourceLocation StartLoc, SourceLocation EndLoc)
+ : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,
+ StartLoc, EndLoc, 0, 1) {}
+
+ /// \brief Build an empty directive.
+ ///
+ explicit OMPSectionDirective()
+ : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,
+ SourceLocation(), SourceLocation(), 0, 1) {}
+
+public:
+ /// \brief Creates directive.
+ ///
+ /// \param C AST context.
+ /// \param StartLoc Starting location of the directive kind.
+ /// \param EndLoc Ending Location of the directive.
+ /// \param AssociatedStmt Statement, associated with the directive.
+ ///
+ static OMPSectionDirective *Create(const ASTContext &C,
+ SourceLocation StartLoc,
+ SourceLocation EndLoc,
+ Stmt *AssociatedStmt);
+
+ /// \brief Creates an empty directive.
+ ///
+ /// \param C AST context.
+ ///
+ static OMPSectionDirective *CreateEmpty(const ASTContext &C, EmptyShell);
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == OMPSectionDirectiveClass;
+ }
+};
+
} // end namespace clang
#endif
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 9be3d8543a..04923dae02 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7115,6 +7115,11 @@ def err_omp_prohibited_region_simd : Error<
"OpenMP constructs may not be nested inside a simd region">;
def err_omp_sections_not_compound_stmt : Error<
"the statement for '#pragma omp sections' must be a compound statement">;
+def err_omp_orphaned_section_directive : Error<
+ "%select{orphaned 'omp section' directives are prohibited, it|'omp section' directive}0"
+ " must be closely nested to a sections region%select{|, not a %1 region}0">;
+def err_omp_sections_substmt_not_section : Error<
+ "statement in 'omp sections' directive must be enclosed into a section region">;
} // end of OpenMP category
let CategoryName = "Related Result Type Issue" in {
diff --git a/include/clang/Basic/OpenMPKinds.def b/include/clang/Basic/OpenMPKinds.def
index 312b975f26..c47782b816 100644
--- a/include/clang/Basic/OpenMPKinds.def
+++ b/include/clang/Basic/OpenMPKinds.def
@@ -47,6 +47,7 @@ OPENMP_DIRECTIVE(task)
OPENMP_DIRECTIVE(simd)
OPENMP_DIRECTIVE(for)
OPENMP_DIRECTIVE(sections)
+OPENMP_DIRECTIVE(section)
// OpenMP clauses.
OPENMP_CLAUSE(if, OMPIfClause)
diff --git a/include/clang/Basic/StmtNodes.td b/include/clang/Basic/StmtNodes.td
index f4ff3ef20f..5236f46883 100644
--- a/include/clang/Basic/StmtNodes.td
+++ b/include/clang/Basic/StmtNodes.td
@@ -181,3 +181,4 @@ def OMPParallelDirective : DStmt<OMPExecutableDirective>;
def OMPSimdDirective : DStmt<OMPExecutableDirective>;
def OMPForDirective : DStmt<OMPExecutableDirective>;
def OMPSectionsDirective : DStmt<OMPExecutableDirective>;
+def OMPSectionDirective : DStmt<OMPExecutableDirective>;
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 6d0eef5d56..0a6cd33b8d 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -7327,6 +7327,10 @@ public:
StmtResult ActOnOpenMPSectionsDirective(ArrayRef<OMPClause *> Clauses,
Stmt *AStmt, SourceLocation StartLoc,
SourceLocation EndLoc);
+ /// \brief Called on well-formed '\#pragma omp section' after parsing of the
+ /// associated statement.
+ StmtResult ActOnOpenMPSectionDirective(Stmt *AStmt, SourceLocation StartLoc,
+ SourceLocation EndLoc);
OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
Expr *Expr,
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h
index 828672e3d6..55cf34fc73 100644
--- a/include/clang/Serialization/ASTBitCodes.h
+++ b/include/clang/Serialization/ASTBitCodes.h
@@ -1343,6 +1343,7 @@ namespace clang {
STMT_OMP_SIMD_DIRECTIVE,
STMT_OMP_FOR_DIRECTIVE,
STMT_OMP_SECTIONS_DIRECTIVE,
+ STMT_OMP_SECTION_DIRECTIVE,
// ARC
EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr