r211774 - [OPENMP] Initial parsing and sema analysis for 'single' directive.
Carlo Bertolli
cbertol at us.ibm.com
Mon Jul 14 10:33:35 PDT 2014
Hi Alexey,
I reviewed and tested this patch - everything seems fine - I only have some
very minor comments (line numbers refer to revision 212940):
- OpenMPKinds.def: line 127
“TODO more clauses allowed for directive ‘omp single’.
I think there are no more clauses allowed for single in OMP 4.0. Consider
removing this comment.
- SemaOpenMP.cpp: line 1898
Missing
assert(AStmt && isa<CapturedStmt>(AStmt) && "Captured statement
expected");
in function ActOnOpenMPSingleDirective.
This seems to be done for all previous directives. Unless I am missing
something, it should be done also for “single”.
- nesting_of_regions.cpp: line 314
This check seems to be a duplicate from line 216.
Thanks
-- Carlo
> Date: Thu, 26 Jun 2014 12:05:46 -0000
> From: Alexey Bataev <a.bataev at hotmail.com>
> To: cfe-commits at cs.uiuc.edu
> Subject: r211774 - [OPENMP] Initial parsing and sema analysis for
> 'single' directive.
> Message-ID: <20140626120547.2AB852A6C02A at llvm.org>
> Content-Type: text/plain; charset="utf-8"
>
> Author: abataev
> Date: Thu Jun 26 07:05:45 2014
> New Revision: 211774
>
> URL: http://llvm.org/viewvc/llvm-project?rev=211774&view=rev
> Log:
> [OPENMP] Initial parsing and sema analysis for 'single' directive.
>
> Added:
> cfe/trunk/test/OpenMP/single_ast_print.cpp (with props)
> cfe/trunk/test/OpenMP/single_firstprivate_messages.cpp (with props)
> cfe/trunk/test/OpenMP/single_misc_messages.c (with props)
> cfe/trunk/test/OpenMP/single_private_messages.cpp (with props)
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> cfe/trunk/include/clang/AST/StmtOpenMP.h
> cfe/trunk/include/clang/Basic/OpenMPKinds.def
> cfe/trunk/include/clang/Basic/StmtNodes.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/AST/Stmt.cpp
> cfe/trunk/lib/AST/StmtPrinter.cpp
> cfe/trunk/lib/AST/StmtProfile.cpp
> cfe/trunk/lib/Basic/OpenMPKinds.cpp
> cfe/trunk/lib/CodeGen/CGStmt.cpp
> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/lib/Parse/ParseOpenMP.cpp
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/lib/Sema/TreeTransform.h
> cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
> cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
> cfe/trunk/test/OpenMP/nesting_of_regions.cpp
> cfe/trunk/tools/libclang/CIndex.cpp
> cfe/trunk/tools/libclang/CXCursor.cpp
>
> Modified: cfe/trunk/include/clang-c/Index.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/
> Index.h?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Thu Jun 26 07:05:45 2014
> @@ -2151,7 +2151,11 @@ enum CXCursorKind {
> */
> CXCursor_OMPSectionDirective = 236,
>
> - CXCursor_LastStmt = CXCursor_OMPSectionDirective,
> + /** \brief OpenMP single directive.
> + */
> + CXCursor_OMPSingleDirective = 237,
> +
> + CXCursor_LastStmt = CXCursor_OMPSingleDirective,
>
> /**
> * \brief Cursor that represents the translation unit itself.
>
> Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
> AST/DataRecursiveASTVisitor.h?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Thu Jun 26
> 07:05:45 2014
> @@ -2305,6 +2305,11 @@ DEF_TRAVERSE_STMT(OMPSectionDirective, {
> return false;
> })
>
> +DEF_TRAVERSE_STMT(OMPSingleDirective, {
> + if (!TraverseOMPExecutableDirective(S))
> + return false;
> +})
> +
> // OpenMP clauses.
> template <typename Derived>
> bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
>
> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
> AST/RecursiveASTVisitor.h?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu Jun 26 07:05:45
2014
> @@ -2327,6 +2327,11 @@ DEF_TRAVERSE_STMT(OMPSectionDirective, {
> return false;
> })
>
> +DEF_TRAVERSE_STMT(OMPSingleDirective, {
> + if (!TraverseOMPExecutableDirective(S))
> + return false;
> +})
> +
> // OpenMP clauses.
> template <typename Derived>
> bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
>
> Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
> AST/StmtOpenMP.h?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
> +++ cfe/trunk/include/clang/AST/StmtOpenMP.h Thu Jun 26 07:05:45 2014
> @@ -470,6 +470,63 @@ public:
> }
> };
>
> +/// \brief This represents '#pragma omp single' directive.
> +///
> +/// \code
> +/// #pragma omp single private(a,b) copyprivate(c,d)
> +/// \endcode
> +/// In this example directive '#pragma omp single' has clauses 'private'
with
> +/// the variables 'a' and 'b' and 'copyprivate' with variables 'c' and
'd'.
> +///
> +class OMPSingleDirective : 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.
> + /// \param NumClauses Number of clauses.
> + ///
> + OMPSingleDirective(SourceLocation StartLoc, SourceLocation EndLoc,
> + unsigned NumClauses)
> + : OMPExecutableDirective(this, OMPSingleDirectiveClass,
OMPD_single,
> + StartLoc, EndLoc, NumClauses, 1) {}
> +
> + /// \brief Build an empty directive.
> + ///
> + /// \param NumClauses Number of clauses.
> + ///
> + explicit OMPSingleDirective(unsigned NumClauses)
> + : OMPExecutableDirective(this, OMPSingleDirectiveClass,
OMPD_single,
> + SourceLocation(), SourceLocation(),
> NumClauses,
> + 1) {}
> +
> +public:
> + /// \brief Creates directive with a list of \a Clauses.
> + ///
> + /// \param C AST context.
> + /// \param StartLoc Starting location of the directive kind.
> + /// \param EndLoc Ending Location of the directive.
> + /// \param Clauses List of clauses.
> + /// \param AssociatedStmt Statement, associated with the directive.
> + ///
> + static OMPSingleDirective *
> + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation
EndLoc,
> + ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
> +
> + /// \brief Creates an empty directive with the place for \a NumClauses
> + /// clauses.
> + ///
> + /// \param C AST context.
> + /// \param NumClauses Number of clauses.
> + ///
> + static OMPSingleDirective *CreateEmpty(const ASTContext &C,
> + unsigned NumClauses,
EmptyShell);
> +
> + static bool classof(const Stmt *T) {
> + return T->getStmtClass() == OMPSingleDirectiveClass;
> + }
> +};
> +
> } // end namespace clang
>
> #endif
>
> Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
> Basic/OpenMPKinds.def?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
> +++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Thu Jun 26 07:05:45
2014
> @@ -30,6 +30,9 @@
> #ifndef OPENMP_SECTIONS_CLAUSE
> # define OPENMP_SECTIONS_CLAUSE(Name)
> #endif
> +#ifndef OPENMP_SINGLE_CLAUSE
> +# define OPENMP_SINGLE_CLAUSE(Name)
> +#endif
> #ifndef OPENMP_DEFAULT_KIND
> # define OPENMP_DEFAULT_KIND(Name)
> #endif
> @@ -48,6 +51,7 @@ OPENMP_DIRECTIVE(simd)
> OPENMP_DIRECTIVE(for)
> OPENMP_DIRECTIVE(sections)
> OPENMP_DIRECTIVE(section)
> +OPENMP_DIRECTIVE(single)
>
> // OpenMP clauses.
> OPENMP_CLAUSE(if, OMPIfClause)
> @@ -104,6 +108,11 @@ OPENMP_SECTIONS_CLAUSE(firstprivate)
> OPENMP_SECTIONS_CLAUSE(reduction)
> OPENMP_SECTIONS_CLAUSE(nowait)
>
> +// TODO more clauses allowed for directive 'omp single'.
> +OPENMP_SINGLE_CLAUSE(private)
> +OPENMP_SINGLE_CLAUSE(firstprivate)
> +OPENMP_SINGLE_CLAUSE(nowait)
> +
> // Static attributes for 'default' clause.
> OPENMP_DEFAULT_KIND(none)
> OPENMP_DEFAULT_KIND(shared)
> @@ -125,6 +134,7 @@ OPENMP_SCHEDULE_KIND(runtime)
> #undef OPENMP_DEFAULT_KIND
> #undef OPENMP_DIRECTIVE
> #undef OPENMP_CLAUSE
> +#undef OPENMP_SINGLE_CLAUSE
> #undef OPENMP_SECTIONS_CLAUSE
> #undef OPENMP_PARALLEL_CLAUSE
> #undef OPENMP_SIMD_CLAUSE
>
> Modified: cfe/trunk/include/clang/Basic/StmtNodes.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
> Basic/StmtNodes.td?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/include/clang/Basic/StmtNodes.td (original)
> +++ cfe/trunk/include/clang/Basic/StmtNodes.td Thu Jun 26 07:05:45 2014
> @@ -182,3 +182,4 @@ def OMPSimdDirective : DStmt<OMPExecutab
> def OMPForDirective : DStmt<OMPExecutableDirective>;
> def OMPSectionsDirective : DStmt<OMPExecutableDirective>;
> def OMPSectionDirective : DStmt<OMPExecutableDirective>;
> +def OMPSingleDirective : DStmt<OMPExecutableDirective>;
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
> Sema/Sema.h?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jun 26 07:05:45 2014
> @@ -7331,6 +7331,11 @@ public:
> /// associated statement.
> StmtResult ActOnOpenMPSectionDirective(Stmt *AStmt,
> SourceLocation StartLoc,
> SourceLocation EndLoc);
> + /// \brief Called on well-formed '\#pragma omp single' after parsing
of the
> + /// associated statement.
> + StmtResult ActOnOpenMPSingleDirective(ArrayRef<OMPClause *> Clauses,
> + Stmt *AStmt,
SourceLocationStartLoc,
> + SourceLocation EndLoc);
>
> OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
> Expr *Expr,
>
> Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
> Serialization/ASTBitCodes.h?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Thu Jun 26
> 07:05:45 2014
> @@ -1344,6 +1344,7 @@ namespace clang {
> STMT_OMP_FOR_DIRECTIVE,
> STMT_OMP_SECTIONS_DIRECTIVE,
> STMT_OMP_SECTION_DIRECTIVE,
> + STMT_OMP_SINGLE_DIRECTIVE,
>
> // ARC
> EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr
>
> Modified: cfe/trunk/lib/AST/Stmt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?
> rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/AST/Stmt.cpp (original)
> +++ cfe/trunk/lib/AST/Stmt.cpp Thu Jun 26 07:05:45 2014
> @@ -1430,3 +1430,29 @@ OMPSectionDirective *OMPSectionDirective
> return new (Mem) OMPSectionDirective();
> }
>
> +OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,
> + SourceLocation StartLoc,
> + SourceLocation EndLoc,
> + ArrayRef<OMPClause *>
Clauses,
> + Stmt *AssociatedStmt) {
> + unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSingleDirective),
> + llvm::alignOf<OMPClause *>
());
> + void *Mem =
> + C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
> sizeof(Stmt *));
> + OMPSingleDirective *Dir =
> + new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size());
> + Dir->setClauses(Clauses);
> + Dir->setAssociatedStmt(AssociatedStmt);
> + return Dir;
> +}
> +
> +OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,
> + unsigned NumClauses,
> + EmptyShell) {
> + unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSingleDirective),
> + llvm::alignOf<OMPClause *>
());
> + void *Mem =
> + C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt
*));
> + return new (Mem) OMPSingleDirective(NumClauses);
> +}
> +
>
> Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> StmtPrinter.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
> +++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Jun 26 07:05:45 2014
> @@ -797,6 +797,11 @@ void StmtPrinter::VisitOMPSectionDirecti
> PrintOMPExecutableDirective(Node);
> }
>
> +void StmtPrinter::VisitOMPSingleDirective(OMPSingleDirective *Node) {
> + Indent() << "#pragma omp single ";
> + PrintOMPExecutableDirective(Node);
> +}
> +
> //
>
===----------------------------------------------------------------------===//
> // Expr printing methods.
> //
>
===----------------------------------------------------------------------===//
>
> Modified: cfe/trunk/lib/AST/StmtProfile.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> StmtProfile.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/AST/StmtProfile.cpp (original)
> +++ cfe/trunk/lib/AST/StmtProfile.cpp Thu Jun 26 07:05:45 2014
> @@ -368,6 +368,10 @@ void StmtProfiler::VisitOMPSectionDirect
> VisitOMPExecutableDirective(S);
> }
>
> +void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S)
{
> + VisitOMPExecutableDirective(S);
> +}
> +
> void StmtProfiler::VisitExpr(const Expr *S) {
> VisitStmt(S);
> }
>
> Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/
> OpenMPKinds.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
> +++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Thu Jun 26 07:05:45 2014
> @@ -201,6 +201,16 @@ bool clang::isAllowedClauseForDirective(
> break;
> }
> break;
> + case OMPD_single:
> + switch (CKind) {
> +#define OPENMP_SINGLE_CLAUSE(Name)
\
> + case OMPC_##Name:
\
> + return true;
> +#include "clang/Basic/OpenMPKinds.def"
> + default:
> + break;
> + }
> + break;
> case OMPD_unknown:
> case OMPD_threadprivate:
> case OMPD_task:
> @@ -215,8 +225,8 @@ bool clang::isOpenMPLoopDirective(OpenMP
> }
>
> bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
> - return DKind == OMPD_for || DKind == OMPD_sections ||
> - DKind == OMPD_section; // TODO add next directives.
> + return DKind == OMPD_for || DKind == OMPD_sections || DKind ==
> OMPD_section ||
> + DKind == OMPD_single; // TODO add next directives.
> }
>
> bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
>
> Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGStmt.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jun 26 07:05:45 2014
> @@ -188,6 +188,9 @@ void CodeGenFunction::EmitStmt(const Stm
> case Stmt::OMPSectionDirectiveClass:
> EmitOMPSectionDirective(cast<OMPSectionDirective>(*S));
> break;
> + case Stmt::OMPSingleDirectiveClass:
> + EmitOMPSingleDirective(cast<OMPSingleDirective>(*S));
> + break;
> }
> }
>
>
> Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGStmtOpenMP.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Jun 26 07:05:45 2014
> @@ -87,3 +87,7 @@ void CodeGenFunction::EmitOMPSectionDire
> llvm_unreachable("CodeGen for 'omp section' is not supported yet.");
> }
>
> +void CodeGenFunction::EmitOMPSingleDirective(const OMPSingleDirective &)
{
> + llvm_unreachable("CodeGen for 'omp single' is not supported yet.");
> +}
> +
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CodeGenFunction.h?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Jun 26 07:05:45 2014
> @@ -1905,6 +1905,7 @@ public:
> void EmitOMPForDirective(const OMPForDirective &S);
> void EmitOMPSectionsDirective(const OMPSectionsDirective &S);
> void EmitOMPSectionDirective(const OMPSectionDirective &S);
> + void EmitOMPSingleDirective(const OMPSingleDirective &S);
>
> //
>
===--------------------------------------------------------------------===//
> // LValue Expression Emission
>
> Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/
> ParseOpenMP.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Thu Jun 26 07:05:45 2014
> @@ -65,6 +65,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpen
> case OMPD_for:
> case OMPD_sections:
> case OMPD_section:
> + case OMPD_single:
> Diag(Tok, diag::err_omp_unexpected_directive)
> << getOpenMPDirectiveName(DKind);
> break;
> @@ -80,8 +81,8 @@ Parser::DeclGroupPtrTy Parser::ParseOpen
> /// annot_pragma_openmp_end
> ///
> /// executable-directive:
> -/// annot_pragma_openmp
'parallel'|'simd'|'for'|'sections'|'section'
> -/// {clause} annot_pragma_openmp_end
> +/// annot_pragma_openmp 'parallel' | 'simd' | 'for' | 'sections'
|
> +/// 'section' | 'single' {clause} annot_pragma_openmp_end
> ///
> StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() {
> assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP
directive!");
> @@ -121,6 +122,7 @@ StmtResult Parser::ParseOpenMPDeclarativ
> case OMPD_simd:
> case OMPD_for:
> case OMPD_sections:
> + case OMPD_single:
> case OMPD_section: {
> ConsumeToken();
>
>
> Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaOpenMP.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jun 26 07:05:45 2014
> @@ -924,6 +924,13 @@ void Sema::ActOnOpenMPRegionStart(OpenMP
> ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP, Params);
> break;
> }
> + case OMPD_single: {
> + Sema::CapturedParamNameType Params[] = {
> + std::make_pair(StringRef(), QualType()) // __context with shared
vars
> + };
> + ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP, Params);
> + break;
> + }
> case OMPD_threadprivate:
> case OMPD_task:
> llvm_unreachable("OpenMP Directive is not allowed");
> @@ -1033,6 +1040,10 @@ StmtResult Sema::ActOnOpenMPExecutableDi
> "No clauses is allowed for 'omp section' directive");
> Res = ActOnOpenMPSectionDirective(AStmt, StartLoc, EndLoc);
> break;
> + case OMPD_single:
> + Res = ActOnOpenMPSingleDirective(ClausesWithImplicit, AStmt,
StartLoc,
> + EndLoc);
> + break;
> case OMPD_threadprivate:
> case OMPD_task:
> llvm_unreachable("OpenMP Directive is not allowed");
> @@ -1647,6 +1658,14 @@ StmtResult Sema::ActOnOpenMPSectionDirec
> return OMPSectionDirective::Create(Context, StartLoc, EndLoc, AStmt);
> }
>
> +StmtResult Sema::ActOnOpenMPSingleDirective(ArrayRef<OMPClause *>
Clauses,
> + Stmt *AStmt,
> + SourceLocation StartLoc,
> + SourceLocation EndLoc) {
> + getCurFunction()->setHasBranchProtectedScope();
> + return OMPSingleDirective::Create(Context, StartLoc, EndLoc,
> Clauses, AStmt);
> +}
> +
> OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
> Expr *Expr,
> SourceLocation StartLoc,
> SourceLocation LParenLoc,
>
> Modified: cfe/trunk/lib/Sema/TreeTransform.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> TreeTransform.h?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/Sema/TreeTransform.h (original)
> +++ cfe/trunk/lib/Sema/TreeTransform.h Thu Jun 26 07:05:45 2014
> @@ -6449,6 +6449,16 @@ TreeTransform<Derived>::TransformOMPSect
> return Res;
> }
>
> +template <typename Derived>
> +StmtResult
> +TreeTransform<Derived>::TransformOMPSingleDirective(OMPSingleDirective
*D) {
> + DeclarationNameInfo DirName;
> + getDerived().getSema().StartOpenMPDSABlock(OMPD_single, DirName,
nullptr);
> + StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
> + getDerived().getSema().EndOpenMPDSABlock(Res.get());
> + return Res;
> +}
> +
> //
>
===----------------------------------------------------------------------===//
> // OpenMP clause transformation
> //
>
===----------------------------------------------------------------------===//
>
> Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Serialization/ASTReaderStmt.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Thu Jun 26 07:05:45
2014
> @@ -1918,6 +1918,13 @@ void ASTStmtReader::VisitOMPSectionDirec
> VisitOMPExecutableDirective(D);
> }
>
> +void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
> + VisitStmt(D);
> + // The NumClauses field was read in ReadStmtFromStream.
> + ++Idx;
> + VisitOMPExecutableDirective(D);
> +}
> +
> //
>
===----------------------------------------------------------------------===//
> // ASTReader Implementation
> //
>
===----------------------------------------------------------------------===//
> @@ -2422,6 +2429,11 @@ Stmt *ASTReader::ReadStmtFromStream(Modu
> S = OMPSectionDirective::CreateEmpty(Context, Empty);
> break;
>
> + case STMT_OMP_SINGLE_DIRECTIVE:
> + S = OMPSingleDirective::CreateEmpty(
> + Context, Record[ASTStmtReader::NumStmtFields], Empty);
> + break;
> +
> case EXPR_CXX_OPERATOR_CALL:
> S = new (Context) CXXOperatorCallExpr(Context, Empty);
> break;
>
> Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Serialization/ASTWriterStmt.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Thu Jun 26 07:05:45
2014
> @@ -1831,6 +1831,13 @@ void ASTStmtWriter::VisitOMPSectionDirec
> Code = serialization::STMT_OMP_SECTION_DIRECTIVE;
> }
>
> +void ASTStmtWriter::VisitOMPSingleDirective(OMPSingleDirective *D) {
> + VisitStmt(D);
> + Record.push_back(D->getNumClauses());
> + VisitOMPExecutableDirective(D);
> + Code = serialization::STMT_OMP_SINGLE_DIRECTIVE;
> +}
> +
> //
>
===----------------------------------------------------------------------===//
> // ASTWriter Implementation
> //
>
===----------------------------------------------------------------------===//
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
>
StaticAnalyzer/Core/ExprEngine.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Thu Jun 26 07:05:45
2014
> @@ -735,6 +735,7 @@ void ExprEngine::Visit(const Stmt *S, Ex
> case Stmt::OMPForDirectiveClass:
> case Stmt::OMPSectionsDirectiveClass:
> case Stmt::OMPSectionDirectiveClass:
> + case Stmt::OMPSingleDirectiveClass:
> llvm_unreachable("Stmt should not be in analyzer evaluation
loop");
>
> case Stmt::ObjCSubscriptRefExprClass:
>
> Modified: cfe/trunk/test/OpenMP/nesting_of_regions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> nesting_of_regions.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/test/OpenMP/nesting_of_regions.cpp (original)
> +++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp Thu Jun 26 07:05:45 2014
> @@ -22,6 +22,9 @@ void foo() {
> {
> bar();
> }
> +#pragma omp parallel
> +#pragma omp single
> + bar();
> #pragma omp simd
> for (int i = 0; i < 10; ++i) {
> #pragma omp for // expected-error {{OpenMP constructs may not be
> nested inside a simd region}}
> @@ -54,6 +57,13 @@ void foo() {
> bar();
> }
> }
> +#pragma omp simd
> + for (int i = 0; i < 10; ++i) {
> +#pragma omp single // expected-error {{OpenMP constructs may not be
> nested inside a simd region}}
> + {
> + bar();
> + }
> + }
> #pragma omp for
> for (int i = 0; i < 10; ++i) {
> #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?}}
> @@ -86,6 +96,13 @@ void foo() {
> bar();
> }
> }
> +#pragma omp for
> + for (int i = 0; i < 10; ++i) {
> +#pragma omp single // expected-error {{region cannot be closely
> nested inside 'for' region; perhaps you forget to enclose 'omp
> single' directive into a parallel region?}}
> + {
> + bar();
> + }
> + }
> #pragma omp sections
> {
> #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?}}
> @@ -118,10 +135,50 @@ void foo() {
> bar();
> }
> }
> +#pragma omp sections
> + {
> +#pragma omp section
> + {
> +#pragma omp single // expected-error {{region cannot be closely
> nested inside 'section' region; perhaps you forget to enclose 'omp
> single' directive into a parallel region?}}
> + bar();
> + }
> + }
> #pragma omp section // expected-error {{orphaned 'omp section'
> directives are prohibited, it must be closely nested to a sections
region}}
> {
> bar();
> }
> +#pragma omp single
> + {
> +#pragma omp for // expected-error {{region cannot be closely nested
> inside 'single' region; perhaps you forget to enclose 'omp for'
> directive into a parallel region?}}
> + for (int i = 0; i < 10; ++i)
> + ;
> + }
> +#pragma omp single
> + {
> +#pragma omp simd
> + for (int i = 0; i < 10; ++i)
> + ;
> + }
> +#pragma omp single
> + {
> +#pragma omp parallel
> + for (int i = 0; i < 10; ++i)
> + ;
> + }
> +#pragma omp single
> + {
> +#pragma omp single // expected-error {{region cannot be closely
> nested inside 'single' region; perhaps you forget to enclose 'omp
> single' directive into a parallel region?}}
> + {
> + bar();
> + }
> + }
> +#pragma omp single
> + {
> +#pragma omp sections // expected-error {{region cannot be closely
> nested inside 'single' region; perhaps you forget to enclose 'omp
> sections' directive into a parallel region?}}
> + {
> + bar();
> + }
> + }
> }
>
> void foo() {
> @@ -143,6 +200,14 @@ void foo() {
> {
> bar();
> }
> +#pragma omp parallel
> +#pragma omp sections
> + {
> + bar();
> + }
> +#pragma omp parallel
> +#pragma omp single
> + bar();
> #pragma omp simd
> for (int i = 0; i < 10; ++i) {
> #pragma omp for // expected-error {{OpenMP constructs may not be
> nested inside a simd region}}
> @@ -175,6 +240,11 @@ void foo() {
> bar();
> }
> }
> +#pragma omp simd
> + for (int i = 0; i < 10; ++i) {
> +#pragma omp single // expected-error {{OpenMP constructs may not be
> nested inside a simd region}}
> + bar();
> + }
> #pragma omp for
> for (int i = 0; i < 10; ++i) {
> #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?}}
> @@ -207,6 +277,11 @@ void foo() {
> bar();
> }
> }
> +#pragma omp for
> + for (int i = 0; i < 10; ++i) {
> +#pragma omp single // expected-error {{region cannot be closely
> nested inside 'for' region; perhaps you forget to enclose 'omp
> single' directive into a parallel region?}}
> + bar();
> + }
> #pragma omp sections
> {
> #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?}}
> @@ -239,10 +314,47 @@ void foo() {
> bar();
> }
> }
> +#pragma omp sections
> + {
> +#pragma omp single // expected-error {{region cannot be closely
> nested inside 'sections' region; perhaps you forget to enclose 'omp
> single' directive into a parallel region?}}
> + bar();
> + }
> #pragma omp section // expected-error {{orphaned 'omp section'
> directives are prohibited, it must be closely nested to a sections
region}}
> {
> bar();
> }
> +#pragma omp single
> + {
> +#pragma omp for // expected-error {{region cannot be closely nested
> inside 'single' region; perhaps you forget to enclose 'omp for'
> directive into a parallel region?}}
> + for (int i = 0; i < 10; ++i)
> + ;
> + }
> +#pragma omp single
> + {
> +#pragma omp simd> + for (int i = 0; i < 10; ++i)
> + ;
> + }
> +#pragma omp single
> + {
> +#pragma omp parallel
> + for (int i = 0; i < 10; ++i)
> + ;
> + }
> +#pragma omp single
> + {
> +#pragma omp single // expected-error {{region cannot be closely
> nested inside 'single' region; perhaps you forget to enclose 'omp
> single' directive into a parallel region?}}
> + {
> + bar();
> + }
> + }
> +#pragma omp single
> + {
> +#pragma omp sections // expected-error {{region cannot be closely
> nested inside 'single' region; perhaps you forget to enclose 'omp
> sections' directive into a parallel region?}}
> + {
> + bar();
> + }
> + }
> return foo<int>();
> }
>
>
> Added: cfe/trunk/test/OpenMP/single_ast_print.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> single_ast_print.cpp?rev=211774&view=auto
>
==============================================================================
> --- cfe/trunk/test/OpenMP/single_ast_print.cpp (added)
> +++ cfe/trunk/test/OpenMP/single_ast_print.cpp Thu Jun 26 07:05:45 2014
> @@ -0,0 +1,38 @@
> +// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck
%s
> +// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t
%s
> +// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -
> fsyntax-only -verify %s -ast-print | FileCheck %s
> +// expected-no-diagnostics
> +
> +#ifndef HEADER
> +#define HEADER
> +
> +void foo() {}
> +
> +template <class T, int N>
> +T tmain(T argc) {
> + T b = argc, c, d, e, f, g;
> + static T a;
> +// CHECK: static T a;
> +#pragma omp parallel
> +#pragma omp single private(argc, b), firstprivate(c, d), nowait
> + foo();
> + // CHECK-NEXT: #pragma omp parallel
> + // CHECK-NEXT: #pragma omp single private(argc,b) firstprivate(c,d)
nowait
> + // CHECK-NEXT: foo();
> + return T();
> +}
> +
> +int main(int argc, char **argv) {
> + int b = argc, c, d, e, f, g;
> + static int a;
> +// CHECK: static int a;
> +#pragma omp parallel
> +#pragma omp single private(argc, b), firstprivate(argv, c), nowait
> + foo();
> + // CHECK-NEXT: #pragma omp parallel
> + // CHECK-NEXT: #pragma omp single private(argc,b) firstprivate
> (argv,c) nowait
> + // CHECK-NEXT: foo();
> + return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
> +}
> +
> +#endif
>
> Propchange: cfe/trunk/test/OpenMP/single_ast_print.cpp
>
------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/OpenMP/single_ast_print.cpp
>
------------------------------------------------------------------------------
> svn:keywords = Author Date Id Rev URL
>
> Propchange: cfe/trunk/test/OpenMP/single_ast_print.cpp
>
------------------------------------------------------------------------------
> svn:mime-type = text/plain
>
> Added: cfe/trunk/test/OpenMP/single_firstprivate_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> single_firstprivate_messages.cpp?rev=211774&view=auto
>
==============================================================================
> --- cfe/trunk/test/OpenMP/single_firstprivate_messages.cpp (added)
> +++ cfe/trunk/test/OpenMP/single_firstprivate_messages.cpp Thu Jun
> 26 07:05:45 2014
> @@ -0,0 +1,239 @@
> +// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
> +
> +void foo() {
> +}
> +
> +bool foobool(int argc) {
> + return argc;
> +}
> +
> +struct S1; // expected-note 2 {{declared here}} expected-note 2
> {{forward declaration of 'S1'}}
> +extern S1 a;
> +class S2 {
> + mutable int a;
> +
> +public:
> + S2() : a(0) {}
> + S2(S2 &s2) : a(s2.a) {}
> + static float S2s;
> + static const float S2sc;
> +};
> +const float S2::S2sc = 0;
> +const S2 b;
> +const S2 ba[5];
> +class S3 {
> + int a;
> + S3 &operator=(const S3 &s3);
> +
> +public:
> + S3() : a(0) {}
> + S3(S3 &s3) : a(s3.a) {}
> +};
> +const S3 c;
> +const S3 ca[5];
> +extern const int f;
> +class S4 { // expected-note 2 {{'S4' declared here}}
> + int a;
> + S4();
> + S4(const S4 &s4);
> +
> +public:
> + S4(int v) : a(v) {}
> +};
> +class S5 { // expected-note 4 {{'S5' declared here}}
> + int a;
> + S5(const S5 &s5) : a(s5.a) {}
> +
> +public:
> + S5() : a(0) {}
> + S5(int v) : a(v) {}
> +};
> +class S6 {
> + int a;
> + S6() : a(0) {}
> +
> +public:
> + S6(const S6 &s6) : a(s6.a) {}
> + S6(int v) : a(v) {}
> +};
> +
> +S3 h;
> +#pragma omp threadprivate(h) // expected-note 2 {{defined as
> threadprivate or thread local}}
> +
> +template <class I, class C>
> +int foomain(int argc, char **argv) {
> + I e(4); // expected-note {{'e' defined here}}
> + C g(5); // expected-note 2 {{'g' defined here}}
> + int i;
> + int &j = i; // expected-note {{'j' defined here}}
> +#pragma omp parallel
> +#pragma omp single firstprivate // expected-error {{expected '('
> after 'firstprivate'}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate( // expected-error {{expected
> expression}} expected-error {{expected ')'}} expected-note {{to
> match this '('}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate() // expected-error {{expected
expression}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(argc // expected-error {{expected
> ')'}} expected-note {{to match this '('}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(argc, // expected-error {{expected
> expression}} expected-error {{expected ')'}} expected-note {{to
> match this '('}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(argc > 0 ? argv[1] : argv[2]) //
> expected-error {{expected variable name}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(argc)
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(S1) // expected-error {{'S1' does
> not refer to a value}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(a, b) // expected-error
> {{firstprivate variable with incomplete type 'S1'}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(argv[1]) // expected-error
> {{expected variable name}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(e, g) // expected-error 2
> {{firstprivate variable must have an accessible, unambiguous copy
> constructor}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(h) // expected-error
> {{threadprivate or thread local variable cannot be firstprivate}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single linear(i) // expected-error {{unexpected OpenMP
> clause 'linear' in directive '#pragma omp single'}}
> + foo();
> +#pragma omp parallel
> + {
> + int v = 0;
> + int i; // expected-note {{variable with
> automatic storage duration is predetermined as private; perhaps you
> forget to enclose 'omp single' directive into a parallel or another
> task region?}}
> +#pragma omp single firstprivate(i) // expected-error {{private
> variable cannot be firstprivate}}
> + foo();
> + v += i;
> + }
> +#pragma omp parallel shared(i)
> +#pragma omp parallel private(i)
> +#pragma omp single firstprivate(j) // expected-error {{arguments of
> OpenMP clause 'firstprivate' cannot be of reference type}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(i)
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(g) // expected-error {{firstprivate
> variable must have an accessible, unambiguous copy constructor}}
> + foo();
> +#pragma omp parallel private(i) // expected-note {{defined as
private}}
> +#pragma omp single firstprivate(i) // expected-error {{firstprivate
> variable must be shared}}
> + foo();
> +#pragma omp parallel reduction(+ : i) // expected-note {{defined as
> reduction}}
> +#pragma omp single firstprivate(i) // expected-error
> {{firstprivate variable must be shared}}
> + foo();
> + return 0;
> +}
> +
> +int main(int argc, char **argv) {
> + const int d = 5;
> + const int da[5] = {0};
> + S4 e(4); // expected-note {{'e' defined here}}
> + S5 g(5); // expected-note 2 {{'g' defined here}}
> + S3 m;
> + S6 n(2);
> + int i;
> + int &j = i; // expected-note {{'j' defined here}}
> +#pragma omp parallel
> +#pragma omp single firstprivate // expected-error {{expected '('
> after 'firstprivate'}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate( // expected-error {{expected
> expression}} expected-error {{expected ')'}} expected-note {{to
> match this '('}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate() // expected-error {{expected
expression}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(argc // expected-error {{expected
> ')'}} expected-note {{to match this '('}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(argc, // expected-error {{expected
> expression}} expected-error {{expected ')'}} expected-note {{to
> match this '('}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(argc > 0 ? argv[1] : argv[2]) //
> expected-error {{expected variable name}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(argc)
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(S1) // expected-error {{'S1' does
> not refer to a value}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(a, b, c, d, f) // expected-error
> {{firstprivate variable with incomplete type 'S1'}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(argv[1]) // expected-error
> {{expected variable name}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(2 * 2) // expected-error {{expected
> variable name}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(ba) // OK
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(ca) // OK
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(da) // OK
> + foo();
> + int xa;
> +#pragma omp parallel
> +#pragma omp single firstprivate(xa) // OK
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(S2::S2s) // OK
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(S2::S2sc) // OK
> + foo();
> +#pragma omp parallel
> +#pragma omp single safelen(5) // expected-error {{unexpected OpenMP
> clause 'safelen' in directive '#pragma omp single'}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(e, g) // expected-error 2
> {{firstprivate variable must have an accessible, unambiguous copy
> constructor}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(m) // OK
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(h) // expected-error
> {{threadprivate or thread local variable cannot be firstprivate}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single private(xa), firstprivate(xa) // expected-error
> {{private variable cannot be firstprivate}} expected-note {{defined
> as private}}
> + foo();
> +#pragma omp parallel shared(xa)
> +#pragma omp single firstprivate(xa) // OK: may be firstprivate
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(j) // expected-error {{arguments of
> OpenMP clause 'firstprivate' cannot be of reference type}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(g) // expected-error {{firstprivate
> variable must have an accessible, unambiguous copy constructor}}
> + foo();
> +#pragma omp parallel
> +#pragma omp single firstprivate(n) // OK
> + foo();
> +#pragma omp parallel
> + {
> + int v = 0;
> + int i; // expected-note {{variable with
> automatic storage duration is predetermined as private; perhaps you
> forget to enclose 'omp single' directive into a parallel or another
> task region?}}
> +#pragma omp single firstprivate(i) // expected-error {{private
> variable cannot be firstprivate}}
> + foo();
> + v += i;
> + }
> +#pragma omp parallel private(i) // expected-note {{defined as
private}}
> +#pragma omp single firstprivate(i) // expected-error {{firstprivate
> variable must be shared}}
> + foo();
> +#pragma omp parallel reduction(+ : i) // expected-note {{defined as
> reduction}}
> +#pragma omp single firstprivate(i) // expected-error
> {{firstprivate variable must be shared}}
> + foo();
> +
> + return foomain<S4, S5>(argc, argv); // expected-note {{in
> instantiation of function template specialization 'foomain<S4, S5>'
> requested here}}
> +}
>
> Propchange: cfe/trunk/test/OpenMP/single_firstprivate_messages.cpp
>
------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/OpenMP/single_firstprivate_messages.cpp
>
------------------------------------------------------------------------------
> svn:keywords = Author Date Id Rev URL
>
> Propchange: cfe/trunk/test/OpenMP/single_firstprivate_messages.cpp
>
------------------------------------------------------------------------------
> svn:mime-type = text/plain
>
> Added: cfe/trunk/test/OpenMP/single_misc_messages.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> single_misc_messages.c?rev=211774&view=auto
>
==============================================================================
> --- cfe/trunk/test/OpenMP/single_misc_messages.c (added)
> +++ cfe/trunk/test/OpenMP/single_misc_messages.c Thu Jun 26 07:05:45 2014
> @@ -0,0 +1,151 @@
> +// RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -verify %s
> +
> +void foo();
> +
> +// expected-error at +1 {{unexpected OpenMP directive '#pragma omp
single'}}
> +#pragma omp single
> +
> +// expected-error at +1 {{unexpected OpenMP directive '#pragma omp
single'}}
> +#pragma omp single foo
> +
> +void test_no_clause() {
> + int i;
> +#pragma omp single
> + foo();
> +
> +#pragma omp single
> + ++i;
> +}
> +
> +void test_branch_protected_scope() {
> + int i = 0;
> +L1:
> + ++i;
> +
> + int x[24];
> +
> +#pragma omp parallel
> +#pragma omp single
> + {
> + if (i == 5)
> + goto L1; // expected-error {{use of undeclared label 'L1'}}
> + else if (i == 6)
> + return; // expected-error {{cannot return from OpenMP region}}
> + else if (i == 7)
> + goto L2;
> + else if (i == 8) {
> + L2:
> + x[i]++;
> + }
> + }
> +
> + if (x[0] == 0)
> + goto L2; // expected-error {{use of undeclared label 'L2'}}
> + else if (x[1] == 1)
> + goto L1;
> +}
> +
> +void test_invalid_clause() {
> + int i;
> +#pragma omp parallel
> +// expected-warning at +1 {{extra tokens at the end of '#pragma omp
> single' are ignored}}
> +#pragma omp single foo bar
> + foo();
> +}
> +
> +void test_non_identifiers() {
> + int i, x;
> +
> +#pragma omp parallel
> +// expected-warning at +1 {{extra tokens at the end of '#pragma omp
> single' are ignored}}
> +#pragma omp single;
> + foo();
> +#pragma omp parallel
> +// expected-error at +2 {{unexpected OpenMP clause 'linear' in
> directive '#pragma omp single'}}
> +// expected-warning at +1 {{extra tokens at the end of '#pragma omp
> single' are ignored}}
> +#pragma omp single linear(x);
> + foo();
> +
> +#pragma omp parallel
> +// expected-warning at +1 {{extra tokens at the end of '#pragma omp
> single' are ignored}}
> +#pragma omp single private(x);
> + foo();
> +
> +#pragma omp parallel
> +// expected-warning at +1 {{extra tokens at the end of '#pragma omp
> single' are ignored}}
> +#pragma omp single, private(x);
> + foo();
> +}
> +
> +void test_private() {
> + int i;
> +#pragma omp parallel
> +// expected-error at +2 {{expected expression}}
> +// expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this
'('}}
> +#pragma omp single private(
> + foo();
> +#pragma omp parallel
> +// expected-error at +2 {{expected ')'}} expected-note at +2 {{to match this
'('}}
> +// expected-error at +1 2 {{expected expression}}
> +#pragma omp single private(,
> + foo();
> +#pragma omp parallel
> +// expected-error at +1 2 {{expected expression}}
> +#pragma omp single private(, )
> + foo();
> +#pragma omp parallel
> +// expected-error at +1 {{expected expression}}
> +#pragma omp single private()
> + foo();
> +#pragma omp parallel
> +// expected-error at +1 {{expected expression}}
> +#pragma omp single private(int)
> + foo();
> +#pragma omp parallel
> +// expected-error at +1 {{expected variable name}}
> +#pragma omp single private(0)
> + foo();
> +
> + int x, y, z;
> +#pragma omp parallel
> +#pragma omp single private(x)
> + foo();
> +#pragma omp parallel
> +#pragma omp single private(x, y)
> + foo();
> +#pragma omp parallel
> +#pragma omp single private(x, y, z)
> + foo();
> +}
> +
> +void test_firstprivate() {
> + int i;
> +#pragma omp parallel
> +// expected-error at +2 {{expected ')'}} expected-note at +2 {{to match this
'('}}
> +// expected-error at +1 {{expected expression}}
> +#pragma omp single firstprivate(
> + foo();
> +
> +#pragma omp parallel
> +// expected-error at +2 {{expected ')'}} expected-note at +2 {{to match this
'('}}
> +// expected-error at +1 2 {{expected expression}}
> +#pragma omp single firstprivate(,
> + foo();
> +#pragma omp parallel
> +// expected-error at +1 2 {{expected expression}}
> +#pragma omp single firstprivate(, )
> + foo();
> +#pragma omp parallel
> +// expected-error at +1 {{expected expression}}
> +#pragma omp single firstprivate()
> + foo();
> +#pragma omp parallel
> +// expected-error at +1 {{expected expression}}
> +#pragma omp single firstprivate(int)
> + foo();
> +#pragma omp parallel
> +// expected-error at +1 {{expected variable name}}
> +#pragma omp single firstprivate(0)
> + foo();
> +}
> +
>
> Propchange: cfe/trunk/test/OpenMP/single_misc_messages.c
>
------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/OpenMP/single_misc_messages.c
>
------------------------------------------------------------------------------
> svn:keywords = Author Date Id Rev URL
>
> Propchange: cfe/trunk/test/OpenMP/single_misc_messages.c
>
------------------------------------------------------------------------------
> svn:mime-type = text/plain
>
> Added: cfe/trunk/test/OpenMP/single_private_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> single_private_messages.cpp?rev=211774&view=auto
>
==============================================================================
> --- cfe/trunk/test/OpenMP/single_private_messages.cpp (added)
> +++ cfe/trunk/test/OpenMP/single_private_messages.cpp Thu Jun 26 07:05:45
2014
> @@ -0,0 +1,140 @@
> +// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
> +
> +void foo() {
> +}
> +
> +bool foobool(int argc) {
> + return argc;
> +}
> +
> +struct S1; // expected-note 2 {{declared here}} expected-note 2
> {{forward declaration of 'S1'}}
> +extern S1 a;
> +class S2 {
> + mutable int a;
> +
> +public:
> + S2() : a(0) {}
> +};
> +const S2 b;
> +const S2 ba[5];
> +class S3 {
> + int a;
> +
> +public:
> + S3() : a(0) {}
> +};
> +const S3 ca[5];
> +class S4 { // expected-note {{'S4' declared here}}
> + int a;
> + S4();
> +
> +public:
> + S4(int v) : a(v) {}
> +};
> +class S5 { // expected-note {{'S5' declared here}}
> + int a;
> + S5() : a(0) {}
> +
> +public:
> + S5(int v) : a(v) {}
> +};
> +
> +S3 h;
> +#pragma omp threadprivate(h) // expected-note 2 {{defined as
> threadprivate or thread local}}
> +
> +template <class I, class C>
> +int foomain(I argc, C **argv) {
> + I e(4);
> + I g(5);
> + int i;
> + int &j = i; // expected-note {{'j' defined here}}
> +#pragma omp single private // expected-error {{expected '(' after
'private'}}
> + foo();
> +#pragma omp single private( // expected-error {{expected
> expression}} expected-error {{expected ')'}} expected-note {{to
> match this '('}}
> + foo();
> +#pragma omp single private() // expected-error {{expected expression}}
> + foo();
> +#pragma omp single private(argc // expected-error {{expected ')'}}
> expected-note {{to match this '('}}
> + foo();
> +#pragma omp single private(argc, // expected-error {{expected
> expression}} expected-error {{expected ')'}} expected-note {{to
> match this '('}}
> + foo();
> +#pragma omp single private(argc > 0 ? argv[1] : argv[2]) //
> expected-error {{expected variable name}}
> + foo();
> +#pragma omp single private(argc)
> + foo();
> +#pragma omp single private(S1) // expected-error {{'S1' does not
> refer to a value}}
> + foo();
> +#pragma omp single private(a, b) // expected-error {{private
> variable with incomplete type 'S1'}}
> + foo();
> +#pragma omp single private(argv[1]) // expected-error {{expected
> variable name}}
> + foo();
> +#pragma omp single private(e, g)
> + foo();
> +#pragma omp single private(h) // expected-error {{threadprivate or
> thread local variable cannot be private}}
> + foo();
> +#pragma omp single shared(i) // expected-error {{unexpected OpenMP
> clause 'shared' in directive '#pragma omp single'}}
> + foo();
> +#pragma omp parallel
> + {
> + int v = 0;
> + int i;
> +#pragma omp single private(i)
> + foo();
> + v += i;
> + }
> +#pragma omp parallel shared(i)
> +#pragma omp parallel private(i)
> +#pragma omp single private(j) // expected-error {{arguments of
> OpenMP clause 'private' cannot be of reference type}}
> + foo();
> +#pragma omp single private(i)
> + foo();
> + return 0;
> +}
> +
> +int main(int argc, char **argv) {
> + S4 e(4); // expected-note {{'e' defined here}}
> + S5 g(5); // expected-note {{'g' defined here}}
> + int i;
> + int &j = i; // expected-note {{'j' defined here}}
> +#pragma omp single private // expected-error {{expected '(' after
'private'}}
> + foo();
> +#pragma omp single private( // expected-error {{expected
> expression}} expected-error {{expected ')'}} expected-note {{to
> match this '('}}
> + foo();
> +#pragma omp single private() // expected-error {{expected expression}}
> + foo();
> +#pragma omp single private(argc // expected-error {{expected ')'}}
> expected-note {{to match this '('}}
> + foo();
> +#pragma omp single private(argc, // expected-error {{expected
> expression}} expected-error {{expected ')'}} expected-note {{to
> match this '('}}
> + foo();
> +#pragma omp single private(argc > 0 ? argv[1] : argv[2]) //
> expected-error {{expected variable name}}
> + foo();
> +#pragma omp single private(argc)
> + foo();
> +#pragma omp single private(S1) // expected-error {{'S1' does not
> refer to a value}}
> + foo();
> +#pragma omp single private(a, b) // expected-error {{private
> variable with incomplete type 'S1'}}
> + foo();
> +#pragma omp single private(argv[1]) // expected-error {{expected
> variable name}}
> + foo();
> +#pragma omp single private(e, g) // expected-error 2 {{private
> variable must have an accessible, unambiguous default constructor}}
> + foo();
> +#pragma omp single private(h) // expected-error {{threadprivate or
> thread local variable cannot be private}}
> + foo();
> +#pragma omp single shared(i) // expected-error {{unexpected OpenMP
> clause 'shared' in directive '#pragma omp single'}}
> + foo();
> +#pragma omp parallel
> + {
> + int i;
> +#pragma omp single private(i)
> + foo();
> + }
> +#pragma omp parallel shared(i)
> +#pragma omp parallel private(i)
> +#pragma omp single private(j) // expected-error {{arguments of
> OpenMP clause 'private' cannot be of reference type}}
> + foo();
> +#pragma omp single private(i)
> + foo();
> +
> + return 0;
> +}
> +
>
> Propchange: cfe/trunk/test/OpenMP/single_private_messages.cpp
>
------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/OpenMP/single_private_messages.cpp
>
------------------------------------------------------------------------------
> svn:keywords = Author Date Id Rev URL
>
> Propchange: cfe/trunk/test/OpenMP/single_private_messages.cpp
>
------------------------------------------------------------------------------
> svn:mime-type = text/plain
>
> Modified: cfe/trunk/tools/libclang/CIndex.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/
> CIndex.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/tools/libclang/CIndex.cpp (original)
> +++ cfe/trunk/tools/libclang/CIndex.cpp Thu Jun 26 07:05:45 2014
> @@ -1854,6 +1854,7 @@ public:
> void VisitOMPForDirective(const OMPForDirective *D);
> void VisitOMPSectionsDirective(const OMPSectionsDirective *D);
> void VisitOMPSectionDirective(const OMPSectionDirective *D);
> + void VisitOMPSingleDirective(const OMPSingleDirective *D);
>
> private:
> void AddDeclarationNameInfo(const Stmt *S);
> @@ -2297,6 +2298,10 @@ void EnqueueVisitor::VisitOMPSectionDire
> VisitOMPExecutableDirective(D);
> }
>
> +void EnqueueVisitor::VisitOMPSingleDirective(const OMPSingleDirective
*D) {
> + VisitOMPExecutableDirective(D);
> +}
> +
> void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, const Stmt *S)
{
> EnqueueVisitor(WL, MakeCXCursor(S, StmtParent,
> TU,RegionOfInterest)).Visit(S);
> }
> @@ -3979,6 +3984,8 @@ CXString clang_getCursorKindSpelling(enu
> return cxstring::createRef("OMPSectionsDirective");
> case CXCursor_OMPSectionDirective:
> return cxstring::createRef("OMPSectionDirective");
> + case CXCursor_OMPSingleDirective:
> + return cxstring::createRef("OMPSingleDirective");
> }
>
> llvm_unreachable("Unhandled CXCursorKind");
>
> Modified: cfe/trunk/tools/libclang/CXCursor.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/
> CXCursor.cpp?rev=211774&r1=211773&r2=211774&view=diff
>
==============================================================================
> --- cfe/trunk/tools/libclang/CXCursor.cpp (original)
> +++ cfe/trunk/tools/libclang/CXCursor.cpp Thu Jun 26 07:05:45 2014
> @@ -528,6 +528,9 @@ CXCursor cxcursor::MakeCXCursor(const St
> case Stmt::OMPSectionDirectiveClass:
> K = CXCursor_OMPSectionDirective;
> break;
> + case Stmt::OMPSingleDirectiveClass:
> + K = CXCursor_OMPSingleDirective;
> + break;
> }
>
> CXCursor C = { K, 0, { Parent, S, TU } };
>
>
>
>
> ------------------------------
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
> End of cfe-commits Digest, Vol 84, Issue 484
> ********************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140714/60e92d57/attachment.html>
More information about the cfe-commits
mailing list