[clang] 7aa9c39 - [Clang][[OpenMP5.1] Initial parser/sema for default(private) clause
Jennifer Yu via cfe-commits
cfe-commits at lists.llvm.org
Thu May 19 12:47:11 PDT 2022
Author: Jennifer Yu
Date: 2022-05-19T12:43:13-07:00
New Revision: 7aa9c39381989134e5d36ec1ea859dc6dc44d8eb
URL: https://github.com/llvm/llvm-project/commit/7aa9c39381989134e5d36ec1ea859dc6dc44d8eb
DIFF: https://github.com/llvm/llvm-project/commit/7aa9c39381989134e5d36ec1ea859dc6dc44d8eb.diff
LOG: [Clang][[OpenMP5.1] Initial parser/sema for default(private) clause
This implements the default(private) clause as defined in OMP5.1
Differential Revision: https://reviews.llvm.org/D125912
Added:
clang/test/OpenMP/default_firstprivate_ast_print.cpp
clang/test/OpenMP/default_private_ast_print.cpp
Modified:
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
clang/test/OpenMP/parallel_default_messages.cpp
clang/test/OpenMP/parallel_for_default_messages.cpp
clang/test/OpenMP/parallel_for_simd_default_messages.cpp
clang/test/OpenMP/parallel_master_codegen.cpp
clang/test/OpenMP/parallel_master_default_messages.cpp
clang/test/OpenMP/parallel_sections_default_messages.cpp
clang/test/OpenMP/target_parallel_default_messages.cpp
clang/test/OpenMP/target_parallel_for_default_messages.cpp
clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
clang/test/OpenMP/target_teams_default_messages.cpp
clang/test/OpenMP/target_teams_distribute_default_messages.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
clang/test/OpenMP/task_default_messages.cpp
clang/test/OpenMP/teams_default_messages.cpp
clang/test/OpenMP/teams_distribute_default_messages.cpp
clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
Removed:
################################################################################
diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html
index b6dc7777f26ec..c206c63e84acb 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1231,11 +1231,12 @@ <h2 id="decl-matchers">Node Matchers</h2>
#pragma omp parallel default(none)
#pragma omp parallel default(shared)
+ #pragma omp parallel default(private)
#pragma omp parallel default(firstprivate)
#pragma omp parallel
-``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, and
-``default(firstprivate)``
+``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``,
+``default(private)`` and ``default(firstprivate)``
</pre></td></tr>
@@ -4715,6 +4716,22 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2>
</pre></td></tr>
+<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>></td><td class="name" onclick="toggle('isPrivateKind0')"><a name="isPrivateKind0Anchor">isFirstPrivateKind</a></td><td></td></tr>
+<tr><td colspan="4" class="doc" id="isPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``private`` kind
+specified.
+
+Given
+
+ #pragma omp parallel
+ #pragma omp parallel default(none)
+ #pragma omp parallel default(shared)
+ #pragma omp parallel default(private)
+ #pragma omp parallel default(firstprivate)
+
+``ompDefaultClause(isFirstPrivateKind())`` matches only
+``default(private)``.
+</pre></td></tr>
+
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>></td><td class="name" onclick="toggle('isFirstPrivateKind0')"><a name="isFirstPrivateKind0Anchor">isFirstPrivateKind</a></td><td></td></tr>
<tr><td colspan="4" class="doc" id="isFirstPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
specified.
@@ -4724,6 +4741,7 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2>
#pragma omp parallel
#pragma omp parallel default(none)
#pragma omp parallel default(shared)
+ #pragma omp parallel default(private)
#pragma omp parallel default(firstprivate)
``ompDefaultClause(isFirstPrivateKind())`` matches only
@@ -4739,6 +4757,7 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2>
#pragma omp parallel
#pragma omp parallel default(none)
#pragma omp parallel default(shared)
+ #pragma omp parallel default(private)
#pragma omp parallel default(firstprivate)
``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
@@ -4753,6 +4772,7 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2>
#pragma omp parallel
#pragma omp parallel default(none)
#pragma omp parallel default(shared)
+ #pragma omp parallel default(private)
#pragma omp parallel default(firstprivate)
``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index d2bffe8fef491..0b51c2b463bd0 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -8303,12 +8303,13 @@ AST_MATCHER_P(OMPExecutableDirective, hasAnyClause,
/// \code
/// #pragma omp parallel default(none)
/// #pragma omp parallel default(shared)
+/// #pragma omp parallel default(private)
/// #pragma omp parallel default(firstprivate)
/// #pragma omp parallel
/// \endcode
///
-/// ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, and
-/// ``default(firstprivate)``
+/// ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``,
+/// `` default(private)`` and ``default(firstprivate)``
extern const internal::VariadicDynCastAllOfMatcher<OMPClause, OMPDefaultClause>
ompDefaultClause;
@@ -8320,6 +8321,7 @@ extern const internal::VariadicDynCastAllOfMatcher<OMPClause, OMPDefaultClause>
/// #pragma omp parallel
/// #pragma omp parallel default(none)
/// #pragma omp parallel default(shared)
+/// #pragma omp parallel default(private)
/// #pragma omp parallel default(firstprivate)
/// \endcode
///
@@ -8336,6 +8338,7 @@ AST_MATCHER(OMPDefaultClause, isNoneKind) {
/// #pragma omp parallel
/// #pragma omp parallel default(none)
/// #pragma omp parallel default(shared)
+/// #pragma omp parallel default(private)
/// #pragma omp parallel default(firstprivate)
/// \endcode
///
@@ -8344,6 +8347,25 @@ AST_MATCHER(OMPDefaultClause, isSharedKind) {
return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_shared;
}
+/// Matches if the OpenMP ``default`` clause has ``private`` kind
+/// specified.
+///
+/// Given
+///
+/// \code
+/// #pragma omp parallel
+/// #pragma omp parallel default(none)
+/// #pragma omp parallel default(shared)
+/// #pragma omp parallel default(private)
+/// #pragma omp parallel default(firstprivate)
+/// \endcode
+///
+/// ``ompDefaultClause(isPrivateKind())`` matches only
+/// ``default(private)``.
+AST_MATCHER(OMPDefaultClause, isPrivateKind) {
+ return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_private;
+}
+
/// Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
/// specified.
///
@@ -8353,6 +8375,7 @@ AST_MATCHER(OMPDefaultClause, isSharedKind) {
/// #pragma omp parallel
/// #pragma omp parallel default(none)
/// #pragma omp parallel default(shared)
+/// #pragma omp parallel default(private)
/// #pragma omp parallel default(firstprivate)
/// \endcode
///
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index a6f93c8941c7c..72629d0aa91e5 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -425,6 +425,7 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(isExpr);
REGISTER_MATCHER(isExternC);
REGISTER_MATCHER(isFinal);
+ REGISTER_MATCHER(isPrivateKind);
REGISTER_MATCHER(isFirstPrivateKind);
REGISTER_MATCHER(isImplicit);
REGISTER_MATCHER(isInStdNamespace);
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 36105981ec259..e3594e1761085 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -1768,7 +1768,7 @@ void Parser::ParseOpenMPEndAssumesDirective(SourceLocation Loc) {
/// Parsing of simple OpenMP clauses like 'default' or 'proc_bind'.
///
/// default-clause:
-/// 'default' '(' 'none' | 'shared' | 'firstprivate' ')
+/// 'default' '(' 'none' | 'shared' | 'private' | 'firstprivate' ')
///
/// proc_bind-clause:
/// 'proc_bind' '(' 'master' | 'close' | 'spread' ')
@@ -3586,7 +3586,7 @@ OMPClause *Parser::ParseOpenMPInteropClause(OpenMPClauseKind Kind,
/// Parsing of simple OpenMP clauses like 'default' or 'proc_bind'.
///
/// default-clause:
-/// 'default' '(' 'none' | 'shared' | 'firstprivate' ')'
+/// 'default' '(' 'none' | 'shared' | 'private' | 'firstprivate' ')'
///
/// proc_bind-clause:
/// 'proc_bind' '(' 'master' | 'close' | 'spread' ')'
@@ -3604,10 +3604,14 @@ OMPClause *Parser::ParseOpenMPSimpleClause(OpenMPClauseKind Kind,
if (!Val || ParseOnly)
return nullptr;
if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
- static_cast<DefaultKind>(Val.getValue().Type) ==
- OMP_DEFAULT_firstprivate) {
+ (static_cast<DefaultKind>(Val.getValue().Type) == OMP_DEFAULT_private ||
+ static_cast<DefaultKind>(Val.getValue().Type) ==
+ OMP_DEFAULT_firstprivate)) {
Diag(Val.getValue().LOpen, diag::err_omp_invalid_dsa)
- << getOpenMPClauseName(OMPC_firstprivate)
+ << getOpenMPClauseName(static_cast<DefaultKind>(Val.getValue().Type) ==
+ OMP_DEFAULT_private
+ ? OMPC_private
+ : OMPC_firstprivate)
<< getOpenMPClauseName(OMPC_default) << "5.1";
return nullptr;
}
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 9f3574e8d0e75..e4305ba8c1718 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -59,7 +59,8 @@ enum DefaultDataSharingAttributes {
DSA_unspecified = 0, /// Data sharing attribute not specified.
DSA_none = 1 << 0, /// Default data sharing attribute 'none'.
DSA_shared = 1 << 1, /// Default data sharing attribute 'shared'.
- DSA_firstprivate = 1 << 2, /// Default data sharing attribute 'firstprivate'.
+ DSA_private = 1 << 2, /// Default data sharing attribute 'private'.
+ DSA_firstprivate = 1 << 3, /// Default data sharing attribute 'firstprivate'.
};
/// Stack for tracking declarations used in OpenMP directives and
@@ -695,6 +696,11 @@ class DSAStackTy {
getTopOfStack().DefaultAttr = DSA_shared;
getTopOfStack().DefaultAttrLoc = Loc;
}
+ /// Set default data sharing attribute to private.
+ void setDefaultDSAPrivate(SourceLocation Loc) {
+ getTopOfStack().DefaultAttr = DSA_private;
+ getTopOfStack().DefaultAttrLoc = Loc;
+ }
/// Set default data sharing attribute to firstprivate.
void setDefaultDSAFirstPrivate(SourceLocation Loc) {
getTopOfStack().DefaultAttr = DSA_firstprivate;
@@ -1233,7 +1239,7 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
case DSA_none:
return DVar;
case DSA_firstprivate:
- if (VD->getStorageDuration() == SD_Static &&
+ if (VD && VD->getStorageDuration() == SD_Static &&
VD->getDeclContext()->isFileContext()) {
DVar.CKind = OMPC_unknown;
} else {
@@ -1241,6 +1247,18 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
}
DVar.ImplicitDSALoc = Iter->DefaultAttrLoc;
return DVar;
+ case DSA_private:
+ // each variable with static storage duration that is declared
+ // in a namespace or global scope and referenced in the construct,
+ // and that does not have a predetermined data-sharing attribute
+ if (VD && VD->getStorageDuration() == SD_Static &&
+ VD->getDeclContext()->isFileContext()) {
+ DVar.CKind = OMPC_unknown;
+ } else {
+ DVar.CKind = OMPC_private;
+ }
+ DVar.ImplicitDSALoc = Iter->DefaultAttrLoc;
+ return DVar;
case DSA_unspecified:
// OpenMP [2.9.1.1, Data-sharing Attribute Rules for Variables Referenced
// in a Construct, implicitly determined, p.2]
@@ -2142,7 +2160,8 @@ bool Sema::isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level,
!cast<OMPCapturedExprDecl>(D)->getInit()->isGLValue()) &&
// If the variable is implicitly firstprivate and scalar - capture by
// copy
- !(DSAStack->getDefaultDSA() == DSA_firstprivate &&
+ !((DSAStack->getDefaultDSA() == DSA_firstprivate ||
+ DSAStack->getDefaultDSA() == DSA_private) &&
!DSAStack->hasExplicitDSA(
D, [](OpenMPClauseKind K, bool) { return K != OMPC_unknown; },
Level) &&
@@ -2290,11 +2309,13 @@ VarDecl *Sema::isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo,
// Global shared must not be captured.
if (VD && !VD->hasLocalStorage() && DVarPrivate.CKind == OMPC_unknown &&
((DSAStack->getDefaultDSA() != DSA_none &&
+ DSAStack->getDefaultDSA() != DSA_private &&
DSAStack->getDefaultDSA() != DSA_firstprivate) ||
DVarTop.CKind == OMPC_shared))
return nullptr;
if (DVarPrivate.CKind != OMPC_unknown ||
(VD && (DSAStack->getDefaultDSA() == DSA_none ||
+ DSAStack->getDefaultDSA() == DSA_private ||
DSAStack->getDefaultDSA() == DSA_firstprivate)))
return VD ? VD : cast<VarDecl>(DVarPrivate.PrivateCopy->getDecl());
}
@@ -2464,7 +2485,11 @@ bool Sema::isOpenMPGlobalCapturedDecl(ValueDecl *D, unsigned Level,
unsigned NumLevels =
getOpenMPCaptureLevels(DSAStack->getDirective(Level));
if (Level == 0)
- return (NumLevels == CaptureLevel + 1) && TopDVar.CKind != OMPC_shared;
+ // non-file scope static variale with default(firstprivate)
+ // should be gloabal captured.
+ return (NumLevels == CaptureLevel + 1 &&
+ (TopDVar.CKind != OMPC_shared ||
+ DSAStack->getDefaultDSA() == DSA_firstprivate));
do {
--Level;
DSAStackTy::DSAVarData DVar = DSAStack->getImplicitDSA(D, Level);
@@ -3444,6 +3469,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
CapturedStmt *CS = nullptr;
const static unsigned DefaultmapKindNum = OMPC_DEFAULTMAP_pointer + 1;
llvm::SmallVector<Expr *, 4> ImplicitFirstprivate;
+ llvm::SmallVector<Expr *, 4> ImplicitPrivate;
llvm::SmallVector<Expr *, 4> ImplicitMap[DefaultmapKindNum][OMPC_MAP_delete];
llvm::SmallVector<OpenMPMapModifierKind, NumberOfOMPMapClauseModifiers>
ImplicitMapModifier[DefaultmapKindNum];
@@ -3539,18 +3565,21 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
// by being listed in a data-sharing attribute clause.
if (DVar.CKind == OMPC_unknown &&
(Stack->getDefaultDSA() == DSA_none ||
+ Stack->getDefaultDSA() == DSA_private ||
Stack->getDefaultDSA() == DSA_firstprivate) &&
isImplicitOrExplicitTaskingRegion(DKind) &&
VarsWithInheritedDSA.count(VD) == 0) {
bool InheritedDSA = Stack->getDefaultDSA() == DSA_none;
- if (!InheritedDSA && Stack->getDefaultDSA() == DSA_firstprivate) {
+ if (!InheritedDSA && (Stack->getDefaultDSA() == DSA_firstprivate ||
+ Stack->getDefaultDSA() == DSA_private)) {
DSAStackTy::DSAVarData DVar =
Stack->getImplicitDSA(VD, /*FromParent=*/false);
InheritedDSA = DVar.CKind == OMPC_unknown;
}
if (InheritedDSA)
VarsWithInheritedDSA[VD] = E;
- return;
+ if (Stack->getDefaultDSA() == DSA_none)
+ return;
}
// OpenMP 5.0 [2.19.7.2, defaultmap clause, Description]
@@ -3558,7 +3587,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
// construct that does not have a predetermined data-sharing attribute
// and does not appear in a to or link clause on a declare target
// directive must be listed in a data-mapping attribute clause, a
- // data-haring attribute clause (including a data-sharing attribute
+ // data-sharing attribute clause (including a data-sharing attribute
// clause on a combined construct where target. is one of the
// constituent constructs), or an is_device_ptr clause.
OpenMPDefaultmapClauseKind ClauseKind =
@@ -3669,10 +3698,16 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
// Define implicit data-sharing attributes for task.
DVar = Stack->getImplicitDSA(VD, /*FromParent=*/false);
if (((isOpenMPTaskingDirective(DKind) && DVar.CKind != OMPC_shared) ||
- (Stack->getDefaultDSA() == DSA_firstprivate &&
- DVar.CKind == OMPC_firstprivate && !DVar.RefExpr)) &&
+ (((Stack->getDefaultDSA() == DSA_firstprivate &&
+ DVar.CKind == OMPC_firstprivate) ||
+ (Stack->getDefaultDSA() == DSA_private &&
+ DVar.CKind == OMPC_private)) &&
+ !DVar.RefExpr)) &&
!Stack->isLoopControlVariable(VD).first) {
- ImplicitFirstprivate.push_back(E);
+ if (Stack->getDefaultDSA() == DSA_private)
+ ImplicitPrivate.push_back(E);
+ else
+ ImplicitFirstprivate.push_back(E);
return;
}
@@ -3888,6 +3923,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
ArrayRef<Expr *> getImplicitFirstprivate() const {
return ImplicitFirstprivate;
}
+ ArrayRef<Expr *> getImplicitPrivate() const { return ImplicitPrivate; }
ArrayRef<Expr *> getImplicitMap(OpenMPDefaultmapClauseKind DK,
OpenMPMapClauseKind MK) const {
return ImplicitMap[DK][MK];
@@ -5882,6 +5918,9 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
SmallVector<Expr *, 4> ImplicitFirstprivates(
DSAChecker.getImplicitFirstprivate().begin(),
DSAChecker.getImplicitFirstprivate().end());
+ SmallVector<Expr *, 4> ImplicitPrivates(
+ DSAChecker.getImplicitPrivate().begin(),
+ DSAChecker.getImplicitPrivate().end());
const unsigned DefaultmapKindNum = OMPC_DEFAULTMAP_pointer + 1;
SmallVector<Expr *, 4> ImplicitMaps[DefaultmapKindNum][OMPC_MAP_delete];
SmallVector<OpenMPMapModifierKind, NumberOfOMPMapClauseModifiers>
@@ -5934,6 +5973,17 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
ErrorFound = true;
}
}
+ if (!ImplicitPrivates.empty()) {
+ if (OMPClause *Implicit =
+ ActOnOpenMPPrivateClause(ImplicitPrivates, SourceLocation(),
+ SourceLocation(), SourceLocation())) {
+ ClausesWithImplicit.push_back(Implicit);
+ ErrorFound = cast<OMPPrivateClause>(Implicit)->varlist_size() !=
+ ImplicitPrivates.size();
+ } else {
+ ErrorFound = true;
+ }
+ }
// OpenMP 5.0 [2.19.7]
// If a list item appears in a reduction, lastprivate or linear
// clause on a combined target construct then it is treated as
@@ -6352,6 +6402,7 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
// Check variables in the clauses if default(none) or
// default(firstprivate) was specified.
if (DSAStack->getDefaultDSA() == DSA_none ||
+ DSAStack->getDefaultDSA() == DSA_private ||
DSAStack->getDefaultDSA() == DSA_firstprivate) {
DSAAttrChecker DSAChecker(DSAStack, *this, nullptr);
for (OMPClause *C : Clauses) {
@@ -6471,6 +6522,7 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
continue;
ErrorFound = true;
if (DSAStack->getDefaultDSA() == DSA_none ||
+ DSAStack->getDefaultDSA() == DSA_private ||
DSAStack->getDefaultDSA() == DSA_firstprivate) {
Diag(P.second->getExprLoc(), diag::err_omp_no_dsa_for_variable)
<< P.first << P.second->getSourceRange();
@@ -16027,6 +16079,9 @@ OMPClause *Sema::ActOnOpenMPDefaultClause(DefaultKind Kind,
case OMP_DEFAULT_firstprivate:
DSAStack->setDefaultDSAFirstPrivate(KindKwLoc);
break;
+ case OMP_DEFAULT_private:
+ DSAStack->setDefaultDSAPrivate(KindKwLoc);
+ break;
default:
llvm_unreachable("DSA unexpected in OpenMP default clause");
}
diff --git a/clang/test/OpenMP/default_firstprivate_ast_print.cpp b/clang/test/OpenMP/default_firstprivate_ast_print.cpp
new file mode 100644
index 0000000000000..22af85db4fc21
--- /dev/null
+++ b/clang/test/OpenMP/default_firstprivate_ast_print.cpp
@@ -0,0 +1,102 @@
+// expected-no-diagnostics
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -emit-pch -o %t %s
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
+
+#ifndef HEADER
+#define HEADER
+
+struct SomeKernel {
+ int targetDev;
+ float devPtr;
+ SomeKernel();
+ ~SomeKernel();
+
+ template <unsigned int nRHS>
+ void apply() {
+#pragma omp parallel default(firstprivate)
+ {
+ targetDev++;
+ }
+ // PRINT: #pragma omp parallel default(firstprivate)
+ // PRINT-NEXT: {
+ // PRINT-NEXT: this->targetDev++;
+ // CHECK-NEXT: }
+ // DUMP: -OMPParallelDirective
+ // DUMP->NEXT: -OMPDefaultClause
+ }
+ // PRINT: template<> void apply<32U>()
+ // PRINT: #pragma omp parallel default(firstprivate)
+ // PRINT-NEXT: {
+ // PRINT-NEXT: this->targetDev++;
+ // CHECK-NEXT: }
+ // DUMP: -OMPParallelDirective
+ // DUMP-NEXT: -OMPDefaultClause
+};
+
+void use_template() {
+ SomeKernel aKern;
+ aKern.apply<32>();
+}
+
+void foo() {
+ int a;
+#pragma omp parallel default(firstprivate)
+ a++;
+ // PRINT: #pragma omp parallel default(firstprivate)
+ // PRINT-NEXT: a++;
+ // DUMP: -OMPParallelDirective
+ // DUMP-NEXT: -OMPDefaultClause
+ // DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
+}
+
+struct St {
+ int a, b;
+ static int y;
+ St() : a(0), b(0) {}
+ ~St() {}
+};
+int St::y = 0;
+void bar() {
+ St a = St();
+ static int yy = 0;
+#pragma omp parallel default(firstprivate)
+ {
+ a.a += 1;
+ a.b += 1;
+ a.y++;
+ yy++;
+ St::y++;
+ }
+ // PRINT: #pragma omp parallel default(firstprivate)
+ // DUMP: -OMPParallelDirective
+ // DUMP-NEXT: -OMPDefaultClause
+ // DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'yy'
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'y'
+}
+#endif // HEADER
diff --git a/clang/test/OpenMP/default_private_ast_print.cpp b/clang/test/OpenMP/default_private_ast_print.cpp
new file mode 100644
index 0000000000000..c0edb4821178d
--- /dev/null
+++ b/clang/test/OpenMP/default_private_ast_print.cpp
@@ -0,0 +1,99 @@
+// expected-no-diagnostics
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -emit-pch -o %t %s
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
+
+#ifndef HEADER
+#define HEADER
+
+struct SomeKernel {
+ int targetDev;
+ float devPtr;
+ SomeKernel();
+ ~SomeKernel();
+
+ template <unsigned int nRHS>
+ void apply() {
+#pragma omp parallel default(private)
+ {
+ targetDev++;
+ }
+ // PRINT: #pragma omp parallel default(private)
+ // PRINT-NEXT: {
+ // PRINT-NEXT: this->targetDev++;
+ // CHECK-NEXT: }
+ // DUMP: -OMPParallelDirective
+ // DUMP->NEXT: -OMPDefaultClause
+ }
+ // PRINT: template<> void apply<32U>()
+ // PRINT: #pragma omp parallel default(private)
+ // PRINT-NEXT: {
+ // PRINT-NEXT: this->targetDev++;
+ // CHECK-NEXT: }
+ // DUMP: -OMPParallelDirective
+ // DUMP-NEXT: -OMPDefaultClause
+};
+
+void use_template() {
+ SomeKernel aKern;
+ aKern.apply<32>();
+}
+
+void foo() {
+ int a;
+#pragma omp parallel default(private)
+ a++;
+ // PRINT: #pragma omp parallel default(private)
+ // PRINT-NEXT: a++;
+ // DUMP: -OMPParallelDirective
+ // DUMP-NEXT: -OMPDefaultClause
+ // DUMP-NEXT: -OMPPrivateClause {{.*}} <implicit>
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
+}
+
+struct St {
+ int a, b;
+ int y;
+ St() : a(0), b(0) {}
+ ~St() {}
+};
+void bar() {
+ St a = St();
+ static int yy = 0;
+#pragma omp parallel default(private)
+ {
+ a.a += 1;
+ a.b += 1;
+ a.y++;
+ yy++;
+ }
+ // PRINT: #pragma omp parallel default(private)
+ // DUMP: -OMPParallelDirective
+ // DUMP-NEXT: -OMPDefaultClause
+ // DUMP-NEXT: -OMPPrivateClause {{.*}} <implicit>
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'yy'
+}
+#endif // HEADER
diff --git a/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp b/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
index 67e4615ae8c01..1eb2ce81460e1 100644
--- a/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
@@ -23,12 +23,12 @@ T tmain(T argc) {
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
@@ -43,7 +43,7 @@ T tmain(T argc) {
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
@@ -71,12 +71,12 @@ int main(int argc, char **argv) {
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
@@ -91,7 +91,7 @@ int main(int argc, char **argv) {
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
@@ -115,6 +115,13 @@ int main(int argc, char **argv) {
++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
}
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
+ for (i = 0; i < argc; ++i) {
+ ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+ ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+ }
#endif
return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0])); // expected-note {{in instantiation of function template specialization 'tmain<int, 5>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<char, 1>' requested here}}
diff --git a/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
index 9aab00f16c48f..c7417fb45e8c2 100644
--- a/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
@@ -23,12 +23,12 @@ T tmain(T argc) {
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for simd default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
@@ -43,7 +43,7 @@ T tmain(T argc) {
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
@@ -71,12 +71,12 @@ int main(int argc, char **argv) {
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for simd default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
@@ -91,7 +91,7 @@ int main(int argc, char **argv) {
foo();
#pragma omp target
#pragma omp teams
-#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target
@@ -107,6 +107,13 @@ int main(int argc, char **argv) {
++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
}
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for simd default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
+ for (i = 0; i < argc; ++i) {
+ ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+ ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+ }
#endif
#pragma omp parallel default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
diff --git a/clang/test/OpenMP/parallel_default_messages.cpp b/clang/test/OpenMP/parallel_default_messages.cpp
index e9d2946b7686a..7db15d7267317 100644
--- a/clang/test/OpenMP/parallel_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_default_messages.cpp
@@ -18,11 +18,10 @@ int main(int argc, char **argv) {
const int c = 0;
#pragma omp parallel default // expected-error {{expected '(' after 'default'}}
-#pragma omp parallel default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-#pragma omp parallel default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp parallel default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
#pragma omp parallel default(none // expected-error {{expected ')'}} expected-note {{to match this '('}}
#pragma omp parallel default(shared), default(shared) // expected-error {{directive '#pragma omp parallel' cannot contain more than one 'default' clause}}
-#pragma omp parallel default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
foo();
#pragma omp parallel default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -41,6 +40,11 @@ int main(int argc, char **argv) {
++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
}
+#pragma omp parallel default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
+ {
+ ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+ ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/parallel_for_default_messages.cpp b/clang/test/OpenMP/parallel_for_default_messages.cpp
index c64b76948c018..6afa1d7817e74 100644
--- a/clang/test/OpenMP/parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_for_default_messages.cpp
@@ -18,10 +18,10 @@ int main(int argc, char **argv) {
#pragma omp parallel for default // expected-error {{expected '(' after 'default'}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel for default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp parallel for default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp parallel for default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
#pragma omp parallel for default(shared), default(shared) // expected-error {{directive '#pragma omp parallel for' cannot contain more than one 'default' clause}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp parallel for default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
@@ -49,6 +49,11 @@ int main(int argc, char **argv) {
++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
}
+#pragma omp parallel for default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
+ for (i = 0; i < argc; ++i) {
+ ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+ ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/parallel_for_simd_default_messages.cpp
index 6368d280de5db..089572298ec7d 100644
--- a/clang/test/OpenMP/parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_for_simd_default_messages.cpp
@@ -18,10 +18,10 @@ int main(int argc, char **argv) {
#pragma omp parallel for simd default // expected-error {{expected '(' after 'default'}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel for simd default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp parallel for simd default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp parallel for simd default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
#pragma omp parallel for simd default(shared), default(shared) // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'default' clause}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp parallel for simd default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
@@ -49,6 +49,11 @@ int main(int argc, char **argv) {
x++; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
y++; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
}
+#pragma omp parallel for default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
+ for (i = 0; i < argc; ++i) {
+ x++; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+ y++; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/parallel_master_codegen.cpp b/clang/test/OpenMP/parallel_master_codegen.cpp
index 511c52d1e1e4f..6105f657b30a6 100644
--- a/clang/test/OpenMP/parallel_master_codegen.cpp
+++ b/clang/test/OpenMP/parallel_master_codegen.cpp
@@ -593,13 +593,18 @@ void parallel_master_allocate() {
// CHECK17-NEXT: entry:
// CHECK17-NEXT: [[A:%.*]] = alloca [[STRUCT_ST:%.*]], align 4
// CHECK17-NEXT: [[Y_CASTED:%.*]] = alloca i64, align 8
+// CHECK17-NEXT: [[Y_CASTED1:%.*]] = alloca i64, align 8
// CHECK17-NEXT: call void @_ZN2StC1Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[A]])
// CHECK17-NEXT: [[TMP0:%.*]] = load i32, i32* @_ZZ36parallel_master_default_firstprivatevE1y, align 4
// CHECK17-NEXT: [[CONV:%.*]] = bitcast i64* [[Y_CASTED]] to i32*
// CHECK17-NEXT: store i32 [[TMP0]], i32* [[CONV]], align 4
// CHECK17-NEXT: [[TMP1:%.*]] = load i64, i64* [[Y_CASTED]], align 8
-// CHECK17-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @[[GLOB1:[0-9]+]], i32 2, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.St*, i64)* @.omp_outlined. to void (i32*, i32*, ...)*), %struct.St* [[A]], i64 [[TMP1]])
-// CHECK17-NEXT: call void @_ZN2StD1Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[A]]) #[[ATTR3:[0-9]+]]
+// CHECK17-NEXT: [[TMP2:%.*]] = load i32, i32* @_ZN2St1yE, align 4
+// CHECK17-NEXT: [[CONV2:%.*]] = bitcast i64* [[Y_CASTED1]] to i32*
+// CHECK17-NEXT: store i32 [[TMP2]], i32* [[CONV2]], align 4
+// CHECK17-NEXT: [[TMP3:%.*]] = load i64, i64* [[Y_CASTED1]], align 8
+// CHECK17-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @[[GLOB1:[0-9]+]], i32 3, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.St*, i64, i64)* @.omp_outlined. to void (i32*, i32*, ...)*), %struct.St* [[A]], i64 [[TMP1]], i64 [[TMP3]])
+// CHECK17-NEXT: call void @_ZN2StD1Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[A]]) #[[ATTR4:[0-9]+]]
// CHECK17-NEXT: ret void
//
//
@@ -614,56 +619,64 @@ void parallel_master_allocate() {
//
//
// CHECK17-LABEL: define {{[^@]+}}@.omp_outlined.
-// CHECK17-SAME: (i32* noalias noundef [[DOTGLOBAL_TID_:%.*]], i32* noalias noundef [[DOTBOUND_TID_:%.*]], %struct.St* noundef nonnull align 4 dereferenceable(8) [[A:%.*]], i64 noundef [[Y:%.*]]) #[[ATTR2:[0-9]+]] {
+// CHECK17-SAME: (i32* noalias noundef [[DOTGLOBAL_TID_:%.*]], i32* noalias noundef [[DOTBOUND_TID_:%.*]], %struct.St* noundef nonnull align 4 dereferenceable(8) [[A:%.*]], i64 noundef [[Y:%.*]], i64 noundef [[Y1:%.*]]) #[[ATTR2:[0-9]+]] {
// CHECK17-NEXT: entry:
// CHECK17-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca i32*, align 8
// CHECK17-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca i32*, align 8
// CHECK17-NEXT: [[A_ADDR:%.*]] = alloca %struct.St*, align 8
// CHECK17-NEXT: [[Y_ADDR:%.*]] = alloca i64, align 8
+// CHECK17-NEXT: [[Y_ADDR2:%.*]] = alloca i64, align 8
+// CHECK17-NEXT: [[A4:%.*]] = alloca [[STRUCT_ST:%.*]], align 4
// CHECK17-NEXT: store i32* [[DOTGLOBAL_TID_]], i32** [[DOTGLOBAL_TID__ADDR]], align 8
// CHECK17-NEXT: store i32* [[DOTBOUND_TID_]], i32** [[DOTBOUND_TID__ADDR]], align 8
// CHECK17-NEXT: store %struct.St* [[A]], %struct.St** [[A_ADDR]], align 8
// CHECK17-NEXT: store i64 [[Y]], i64* [[Y_ADDR]], align 8
+// CHECK17-NEXT: store i64 [[Y1]], i64* [[Y_ADDR2]], align 8
// CHECK17-NEXT: [[TMP0:%.*]] = load %struct.St*, %struct.St** [[A_ADDR]], align 8
// CHECK17-NEXT: [[CONV:%.*]] = bitcast i64* [[Y_ADDR]] to i32*
-// CHECK17-NEXT: [[TMP1:%.*]] = load i32*, i32** [[DOTGLOBAL_TID__ADDR]], align 8
-// CHECK17-NEXT: [[TMP2:%.*]] = load i32, i32* [[TMP1]], align 4
-// CHECK17-NEXT: [[TMP3:%.*]] = call i32 @__kmpc_master(%struct.ident_t* @[[GLOB1]], i32 [[TMP2]])
-// CHECK17-NEXT: [[TMP4:%.*]] = icmp ne i32 [[TMP3]], 0
-// CHECK17-NEXT: br i1 [[TMP4]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_END:%.*]]
+// CHECK17-NEXT: [[CONV3:%.*]] = bitcast i64* [[Y_ADDR2]] to i32*
+// CHECK17-NEXT: [[TMP1:%.*]] = bitcast %struct.St* [[A4]] to i8*
+// CHECK17-NEXT: [[TMP2:%.*]] = bitcast %struct.St* [[TMP0]] to i8*
+// CHECK17-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[TMP1]], i8* align 4 [[TMP2]], i64 8, i1 false)
+// CHECK17-NEXT: [[TMP3:%.*]] = load i32*, i32** [[DOTGLOBAL_TID__ADDR]], align 8
+// CHECK17-NEXT: [[TMP4:%.*]] = load i32, i32* [[TMP3]], align 4
+// CHECK17-NEXT: [[TMP5:%.*]] = call i32 @__kmpc_master(%struct.ident_t* @[[GLOB1]], i32 [[TMP4]])
+// CHECK17-NEXT: [[TMP6:%.*]] = icmp ne i32 [[TMP5]], 0
+// CHECK17-NEXT: br i1 [[TMP6]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_END:%.*]]
// CHECK17: omp_if.then:
-// CHECK17-NEXT: [[A1:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], %struct.St* [[TMP0]], i32 0, i32 0
-// CHECK17-NEXT: [[TMP5:%.*]] = load i32, i32* [[A1]], align 4
-// CHECK17-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP5]], 1
-// CHECK17-NEXT: store i32 [[ADD]], i32* [[A1]], align 4
-// CHECK17-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_ST]], %struct.St* [[TMP0]], i32 0, i32 1
-// CHECK17-NEXT: [[TMP6:%.*]] = load i32, i32* [[B]], align 4
-// CHECK17-NEXT: [[ADD2:%.*]] = add nsw i32 [[TMP6]], 1
-// CHECK17-NEXT: store i32 [[ADD2]], i32* [[B]], align 4
-// CHECK17-NEXT: [[TMP7:%.*]] = load i32, i32* [[CONV]], align 4
-// CHECK17-NEXT: [[INC:%.*]] = add nsw i32 [[TMP7]], 1
+// CHECK17-NEXT: [[A5:%.*]] = getelementptr inbounds [[STRUCT_ST]], %struct.St* [[A4]], i32 0, i32 0
+// CHECK17-NEXT: [[TMP7:%.*]] = load i32, i32* [[A5]], align 4
+// CHECK17-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP7]], 1
+// CHECK17-NEXT: store i32 [[ADD]], i32* [[A5]], align 4
+// CHECK17-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_ST]], %struct.St* [[A4]], i32 0, i32 1
+// CHECK17-NEXT: [[TMP8:%.*]] = load i32, i32* [[B]], align 4
+// CHECK17-NEXT: [[ADD6:%.*]] = add nsw i32 [[TMP8]], 1
+// CHECK17-NEXT: store i32 [[ADD6]], i32* [[B]], align 4
+// CHECK17-NEXT: [[TMP9:%.*]] = load i32, i32* [[CONV]], align 4
+// CHECK17-NEXT: [[INC:%.*]] = add nsw i32 [[TMP9]], 1
// CHECK17-NEXT: store i32 [[INC]], i32* [[CONV]], align 4
-// CHECK17-NEXT: [[TMP8:%.*]] = load i32, i32* @_ZN2St1yE, align 4
-// CHECK17-NEXT: [[INC3:%.*]] = add nsw i32 [[TMP8]], 1
-// CHECK17-NEXT: store i32 [[INC3]], i32* @_ZN2St1yE, align 4
-// CHECK17-NEXT: call void @__kmpc_end_master(%struct.ident_t* @[[GLOB1]], i32 [[TMP2]])
+// CHECK17-NEXT: [[TMP10:%.*]] = load i32, i32* @_ZN2St1yE, align 4
+// CHECK17-NEXT: [[INC7:%.*]] = add nsw i32 [[TMP10]], 1
+// CHECK17-NEXT: store i32 [[INC7]], i32* @_ZN2St1yE, align 4
+// CHECK17-NEXT: call void @__kmpc_end_master(%struct.ident_t* @[[GLOB1]], i32 [[TMP4]])
// CHECK17-NEXT: br label [[OMP_IF_END]]
// CHECK17: omp_if.end:
+// CHECK17-NEXT: call void @_ZN2StD1Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[A4]]) #[[ATTR4]]
// CHECK17-NEXT: ret void
//
//
// CHECK17-LABEL: define {{[^@]+}}@_ZN2StD1Ev
-// CHECK17-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR4:[0-9]+]] comdat align 2 {
+// CHECK17-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR5:[0-9]+]] comdat align 2 {
// CHECK17-NEXT: entry:
// CHECK17-NEXT: [[THIS_ADDR:%.*]] = alloca %struct.St*, align 8
// CHECK17-NEXT: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]], align 8
// CHECK17-NEXT: [[THIS1:%.*]] = load %struct.St*, %struct.St** [[THIS_ADDR]], align 8
-// CHECK17-NEXT: call void @_ZN2StD2Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS1]]) #[[ATTR3]]
+// CHECK17-NEXT: call void @_ZN2StD2Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS1]]) #[[ATTR4]]
// CHECK17-NEXT: ret void
//
//
// CHECK17-LABEL: define {{[^@]+}}@_ZN2StC2Ev
-// CHECK17-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR4]] comdat align 2 {
+// CHECK17-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR5]] comdat align 2 {
// CHECK17-NEXT: entry:
// CHECK17-NEXT: [[THIS_ADDR:%.*]] = alloca %struct.St*, align 8
// CHECK17-NEXT: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]], align 8
@@ -676,7 +689,7 @@ void parallel_master_allocate() {
//
//
// CHECK17-LABEL: define {{[^@]+}}@_ZN2StD2Ev
-// CHECK17-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR4]] comdat align 2 {
+// CHECK17-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR5]] comdat align 2 {
// CHECK17-NEXT: entry:
// CHECK17-NEXT: [[THIS_ADDR:%.*]] = alloca %struct.St*, align 8
// CHECK17-NEXT: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]], align 8
@@ -689,13 +702,18 @@ void parallel_master_allocate() {
// CHECK18-NEXT: entry:
// CHECK18-NEXT: [[A:%.*]] = alloca [[STRUCT_ST:%.*]], align 4
// CHECK18-NEXT: [[Y_CASTED:%.*]] = alloca i64, align 8
+// CHECK18-NEXT: [[Y_CASTED1:%.*]] = alloca i64, align 8
// CHECK18-NEXT: call void @_ZN2StC1Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[A]])
// CHECK18-NEXT: [[TMP0:%.*]] = load i32, i32* @_ZZ36parallel_master_default_firstprivatevE1y, align 4
// CHECK18-NEXT: [[CONV:%.*]] = bitcast i64* [[Y_CASTED]] to i32*
// CHECK18-NEXT: store i32 [[TMP0]], i32* [[CONV]], align 4
// CHECK18-NEXT: [[TMP1:%.*]] = load i64, i64* [[Y_CASTED]], align 8
-// CHECK18-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @[[GLOB1:[0-9]+]], i32 2, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.St*, i64)* @.omp_outlined. to void (i32*, i32*, ...)*), %struct.St* [[A]], i64 [[TMP1]])
-// CHECK18-NEXT: call void @_ZN2StD1Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[A]]) #[[ATTR3:[0-9]+]]
+// CHECK18-NEXT: [[TMP2:%.*]] = load i32, i32* @_ZN2St1yE, align 4
+// CHECK18-NEXT: [[CONV2:%.*]] = bitcast i64* [[Y_CASTED1]] to i32*
+// CHECK18-NEXT: store i32 [[TMP2]], i32* [[CONV2]], align 4
+// CHECK18-NEXT: [[TMP3:%.*]] = load i64, i64* [[Y_CASTED1]], align 8
+// CHECK18-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @[[GLOB1:[0-9]+]], i32 3, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.St*, i64, i64)* @.omp_outlined. to void (i32*, i32*, ...)*), %struct.St* [[A]], i64 [[TMP1]], i64 [[TMP3]])
+// CHECK18-NEXT: call void @_ZN2StD1Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[A]]) #[[ATTR4:[0-9]+]]
// CHECK18-NEXT: ret void
//
//
@@ -710,56 +728,64 @@ void parallel_master_allocate() {
//
//
// CHECK18-LABEL: define {{[^@]+}}@.omp_outlined.
-// CHECK18-SAME: (i32* noalias noundef [[DOTGLOBAL_TID_:%.*]], i32* noalias noundef [[DOTBOUND_TID_:%.*]], %struct.St* noundef nonnull align 4 dereferenceable(8) [[A:%.*]], i64 noundef [[Y:%.*]]) #[[ATTR2:[0-9]+]] {
+// CHECK18-SAME: (i32* noalias noundef [[DOTGLOBAL_TID_:%.*]], i32* noalias noundef [[DOTBOUND_TID_:%.*]], %struct.St* noundef nonnull align 4 dereferenceable(8) [[A:%.*]], i64 noundef [[Y:%.*]], i64 noundef [[Y1:%.*]]) #[[ATTR2:[0-9]+]] {
// CHECK18-NEXT: entry:
// CHECK18-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca i32*, align 8
// CHECK18-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca i32*, align 8
// CHECK18-NEXT: [[A_ADDR:%.*]] = alloca %struct.St*, align 8
// CHECK18-NEXT: [[Y_ADDR:%.*]] = alloca i64, align 8
+// CHECK18-NEXT: [[Y_ADDR2:%.*]] = alloca i64, align 8
+// CHECK18-NEXT: [[A4:%.*]] = alloca [[STRUCT_ST:%.*]], align 4
// CHECK18-NEXT: store i32* [[DOTGLOBAL_TID_]], i32** [[DOTGLOBAL_TID__ADDR]], align 8
// CHECK18-NEXT: store i32* [[DOTBOUND_TID_]], i32** [[DOTBOUND_TID__ADDR]], align 8
// CHECK18-NEXT: store %struct.St* [[A]], %struct.St** [[A_ADDR]], align 8
// CHECK18-NEXT: store i64 [[Y]], i64* [[Y_ADDR]], align 8
+// CHECK18-NEXT: store i64 [[Y1]], i64* [[Y_ADDR2]], align 8
// CHECK18-NEXT: [[TMP0:%.*]] = load %struct.St*, %struct.St** [[A_ADDR]], align 8
// CHECK18-NEXT: [[CONV:%.*]] = bitcast i64* [[Y_ADDR]] to i32*
-// CHECK18-NEXT: [[TMP1:%.*]] = load i32*, i32** [[DOTGLOBAL_TID__ADDR]], align 8
-// CHECK18-NEXT: [[TMP2:%.*]] = load i32, i32* [[TMP1]], align 4
-// CHECK18-NEXT: [[TMP3:%.*]] = call i32 @__kmpc_master(%struct.ident_t* @[[GLOB1]], i32 [[TMP2]])
-// CHECK18-NEXT: [[TMP4:%.*]] = icmp ne i32 [[TMP3]], 0
-// CHECK18-NEXT: br i1 [[TMP4]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_END:%.*]]
+// CHECK18-NEXT: [[CONV3:%.*]] = bitcast i64* [[Y_ADDR2]] to i32*
+// CHECK18-NEXT: [[TMP1:%.*]] = bitcast %struct.St* [[A4]] to i8*
+// CHECK18-NEXT: [[TMP2:%.*]] = bitcast %struct.St* [[TMP0]] to i8*
+// CHECK18-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[TMP1]], i8* align 4 [[TMP2]], i64 8, i1 false)
+// CHECK18-NEXT: [[TMP3:%.*]] = load i32*, i32** [[DOTGLOBAL_TID__ADDR]], align 8
+// CHECK18-NEXT: [[TMP4:%.*]] = load i32, i32* [[TMP3]], align 4
+// CHECK18-NEXT: [[TMP5:%.*]] = call i32 @__kmpc_master(%struct.ident_t* @[[GLOB1]], i32 [[TMP4]])
+// CHECK18-NEXT: [[TMP6:%.*]] = icmp ne i32 [[TMP5]], 0
+// CHECK18-NEXT: br i1 [[TMP6]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_END:%.*]]
// CHECK18: omp_if.then:
-// CHECK18-NEXT: [[A1:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], %struct.St* [[TMP0]], i32 0, i32 0
-// CHECK18-NEXT: [[TMP5:%.*]] = load i32, i32* [[A1]], align 4
-// CHECK18-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP5]], 1
-// CHECK18-NEXT: store i32 [[ADD]], i32* [[A1]], align 4
-// CHECK18-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_ST]], %struct.St* [[TMP0]], i32 0, i32 1
-// CHECK18-NEXT: [[TMP6:%.*]] = load i32, i32* [[B]], align 4
-// CHECK18-NEXT: [[ADD2:%.*]] = add nsw i32 [[TMP6]], 1
-// CHECK18-NEXT: store i32 [[ADD2]], i32* [[B]], align 4
-// CHECK18-NEXT: [[TMP7:%.*]] = load i32, i32* [[CONV]], align 4
-// CHECK18-NEXT: [[INC:%.*]] = add nsw i32 [[TMP7]], 1
+// CHECK18-NEXT: [[A5:%.*]] = getelementptr inbounds [[STRUCT_ST]], %struct.St* [[A4]], i32 0, i32 0
+// CHECK18-NEXT: [[TMP7:%.*]] = load i32, i32* [[A5]], align 4
+// CHECK18-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP7]], 1
+// CHECK18-NEXT: store i32 [[ADD]], i32* [[A5]], align 4
+// CHECK18-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_ST]], %struct.St* [[A4]], i32 0, i32 1
+// CHECK18-NEXT: [[TMP8:%.*]] = load i32, i32* [[B]], align 4
+// CHECK18-NEXT: [[ADD6:%.*]] = add nsw i32 [[TMP8]], 1
+// CHECK18-NEXT: store i32 [[ADD6]], i32* [[B]], align 4
+// CHECK18-NEXT: [[TMP9:%.*]] = load i32, i32* [[CONV]], align 4
+// CHECK18-NEXT: [[INC:%.*]] = add nsw i32 [[TMP9]], 1
// CHECK18-NEXT: store i32 [[INC]], i32* [[CONV]], align 4
-// CHECK18-NEXT: [[TMP8:%.*]] = load i32, i32* @_ZN2St1yE, align 4
-// CHECK18-NEXT: [[INC3:%.*]] = add nsw i32 [[TMP8]], 1
-// CHECK18-NEXT: store i32 [[INC3]], i32* @_ZN2St1yE, align 4
-// CHECK18-NEXT: call void @__kmpc_end_master(%struct.ident_t* @[[GLOB1]], i32 [[TMP2]])
+// CHECK18-NEXT: [[TMP10:%.*]] = load i32, i32* @_ZN2St1yE, align 4
+// CHECK18-NEXT: [[INC7:%.*]] = add nsw i32 [[TMP10]], 1
+// CHECK18-NEXT: store i32 [[INC7]], i32* @_ZN2St1yE, align 4
+// CHECK18-NEXT: call void @__kmpc_end_master(%struct.ident_t* @[[GLOB1]], i32 [[TMP4]])
// CHECK18-NEXT: br label [[OMP_IF_END]]
// CHECK18: omp_if.end:
+// CHECK18-NEXT: call void @_ZN2StD1Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[A4]]) #[[ATTR4]]
// CHECK18-NEXT: ret void
//
//
// CHECK18-LABEL: define {{[^@]+}}@_ZN2StD1Ev
-// CHECK18-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR4:[0-9]+]] comdat align 2 {
+// CHECK18-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR5:[0-9]+]] comdat align 2 {
// CHECK18-NEXT: entry:
// CHECK18-NEXT: [[THIS_ADDR:%.*]] = alloca %struct.St*, align 8
// CHECK18-NEXT: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]], align 8
// CHECK18-NEXT: [[THIS1:%.*]] = load %struct.St*, %struct.St** [[THIS_ADDR]], align 8
-// CHECK18-NEXT: call void @_ZN2StD2Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS1]]) #[[ATTR3]]
+// CHECK18-NEXT: call void @_ZN2StD2Ev(%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS1]]) #[[ATTR4]]
// CHECK18-NEXT: ret void
//
//
// CHECK18-LABEL: define {{[^@]+}}@_ZN2StC2Ev
-// CHECK18-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR4]] comdat align 2 {
+// CHECK18-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR5]] comdat align 2 {
// CHECK18-NEXT: entry:
// CHECK18-NEXT: [[THIS_ADDR:%.*]] = alloca %struct.St*, align 8
// CHECK18-NEXT: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]], align 8
@@ -772,7 +798,7 @@ void parallel_master_allocate() {
//
//
// CHECK18-LABEL: define {{[^@]+}}@_ZN2StD2Ev
-// CHECK18-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR4]] comdat align 2 {
+// CHECK18-SAME: (%struct.St* noundef nonnull align 4 dereferenceable(8) [[THIS:%.*]]) unnamed_addr #[[ATTR5]] comdat align 2 {
// CHECK18-NEXT: entry:
// CHECK18-NEXT: [[THIS_ADDR:%.*]] = alloca %struct.St*, align 8
// CHECK18-NEXT: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]], align 8
diff --git a/clang/test/OpenMP/parallel_master_default_messages.cpp b/clang/test/OpenMP/parallel_master_default_messages.cpp
index 39f78ea53ae16..992b589c46a76 100644
--- a/clang/test/OpenMP/parallel_master_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_master_default_messages.cpp
@@ -16,17 +16,16 @@ static int x = 0;
int main(int argc, char **argv) {
#pragma omp parallel master default // expected-error {{expected '(' after 'default'}}
{
-#pragma omp parallel master default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- {
-#pragma omp parallel master default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp parallel master default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
+#pragma omp parallel master default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
+ {
#pragma omp parallel master default(none // expected-error {{expected ')'}} expected-note {{to match this '('}}
- {
+ {
#pragma omp parallel master default(shared), default(shared) // expected-error {{directive '#pragma omp parallel master' cannot contain more than one 'default' clause}}
- {
-#pragma omp parallel master default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
- {
- foo();
+ {
+#pragma omp parallel master default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
+ {foo();
}
}
}
@@ -53,6 +52,11 @@ int main(int argc, char **argv) {
++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
}
+#pragma omp parallel master default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
+ {
+ ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+ ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/parallel_sections_default_messages.cpp b/clang/test/OpenMP/parallel_sections_default_messages.cpp
index cfa95445fb536..a319269780247 100644
--- a/clang/test/OpenMP/parallel_sections_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_sections_default_messages.cpp
@@ -1,23 +1,30 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s \
+// RUN: -Wuninitialized
-// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s \
+// RUN: -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s \
+// RUN: -fopenmp-version=51 -DOMP51 -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s \
+// RUN: -fopenmp-version=51 -DOMP51 -Wuninitialized
void foo();
int main(int argc, char **argv) {
#pragma omp parallel sections default // expected-error {{expected '(' after 'default'}}
{
-#pragma omp parallel sections default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
- {
-#pragma omp parallel sections default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp parallel sections default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{
+#pragma omp parallel sections default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
+ {
#pragma omp parallel sections default(none // expected-error {{expected ')'}} expected-note {{to match this '('}}
- {
+ {
#pragma omp parallel sections default(shared), default(shared) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'default' clause}}
- {
-#pragma omp parallel sections default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
- {
- foo();
+ {
+#pragma omp parallel sections default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
+ {foo();
}
}
}
@@ -37,5 +44,15 @@ int main(int argc, char **argv) {
++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
}
}
+
+#ifdef OMP51
+#pragma omp parallel sections default(none) // expected-note {{explicit data sharing attribute requested here}}
+ {
+#pragma omp parallel sections default(private)
+ {
+ ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+ }
+ }
+#endif // OMP51
return 0;
}
diff --git a/clang/test/OpenMP/target_parallel_default_messages.cpp b/clang/test/OpenMP/target_parallel_default_messages.cpp
index c8f68659438fe..254499aff8408 100644
--- a/clang/test/OpenMP/target_parallel_default_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_default_messages.cpp
@@ -16,15 +16,15 @@ static int x = 0;
int main(int argc, char **argv) {
#pragma omp target parallel default // expected-error {{expected '(' after 'default'}}
foo();
-#pragma omp target parallel default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target parallel default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
foo();
-#pragma omp target parallel default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target parallel default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
foo();
#pragma omp target parallel default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
foo();
#pragma omp target parallel default (shared), default(shared) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'default' clause}}
foo();
-#pragma omp target parallel default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target parallel default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
foo();
#pragma omp target parallel default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -44,6 +44,11 @@ int main(int argc, char **argv) {
++x;
++y;
}
+#pragma omp target parallel default(private) // expected-error {{data-sharing attribute 'private' in 'default' clause requires OpenMP version 5.1 or above}}
+ {
+ ++x;
+ ++y;
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/target_parallel_for_default_messages.cpp b/clang/test/OpenMP/target_parallel_for_default_messages.cpp
index 4a3aae68e0865..681d96bd10b2c 100644
--- a/clang/test/OpenMP/target_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_for_default_messages.cpp
@@ -18,10 +18,10 @@ int main(int argc, char **argv) {
#pragma omp target parallel for default // expected-error {{expected '(' after 'default'}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp target parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target parallel for default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp target parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target parallel for default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target parallel for default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
#pragma omp target parallel for default(shared), default(shared) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'default' clause}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp target parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target parallel for default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
@@ -49,6 +49,11 @@ int main(int argc, char **argv) {
++x;
++y;
}
+#pragma omp target parallel for default(private) // expected-error {{data-sharing attribute 'private' in 'default' clause requires OpenMP version 5.1 or above}}
+ for (i = 0; i < argc; ++i) {
+ ++x;
+ ++y;
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
index 48489309ef037..66df9b5cf048f 100644
--- a/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
@@ -18,10 +18,10 @@ int main(int argc, char **argv) {
#pragma omp target parallel for simd default // expected-error {{expected '(' after 'default'}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp target parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target parallel for simd default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp target parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target parallel for simd default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
#pragma omp target parallel for simd default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
#pragma omp target parallel for simd default(shared), default(shared) // expected-error {{directive '#pragma omp target parallel for simd' cannot contain more than one 'default' clause}}
for (i = 0; i < argc; ++i)
foo();
-#pragma omp target parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target parallel for simd default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (i = 0; i < argc; ++i)
foo();
@@ -49,6 +49,11 @@ int main(int argc, char **argv) {
++x;
++y;
}
+#pragma omp target parallel for simd default(private) // expected-error {{data-sharing attribute 'private' in 'default' clause requires OpenMP version 5.1 or above}}
+ for (int i = 0; i < argc; i++) {
+ ++x;
+ ++y;
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/target_teams_default_messages.cpp b/clang/test/OpenMP/target_teams_default_messages.cpp
index 85c417f8f9853..629df8fb9240b 100644
--- a/clang/test/OpenMP/target_teams_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_default_messages.cpp
@@ -16,15 +16,15 @@ static int x = 0;
int main(int argc, char **argv) {
#pragma omp target teams default // expected-error {{expected '(' after 'default'}}
foo();
-#pragma omp target teams default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
foo();
-#pragma omp target teams default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target teams default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
foo();
#pragma omp target teams default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
foo();
#pragma omp target teams default (shared), default(shared) // expected-error {{directive '#pragma omp target teams' cannot contain more than one 'default' clause}}
foo();
-#pragma omp target teams default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target teams default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
foo();
#pragma omp target teams default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -40,6 +40,11 @@ int main(int argc, char **argv) {
++x;
++y;
}
+#pragma omp target teams default(private) // expected-error {{data-sharing attribute 'private' in 'default' clause requires OpenMP version 5.1 or above}}
+ {
+ ++x;
+ ++y;
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/target_teams_distribute_default_messages.cpp b/clang/test/OpenMP/target_teams_distribute_default_messages.cpp
index a490ad61385ff..90615c3cfb8c0 100644
--- a/clang/test/OpenMP/target_teams_distribute_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_default_messages.cpp
@@ -16,15 +16,15 @@ static int x = 0;
int main(int argc, char **argv) {
#pragma omp target teams distribute default // expected-error {{expected '(' after 'default'}}
for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams distribute default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target teams distribute default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target teams distribute default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int i=0; i<200; i++) foo();
#pragma omp target teams distribute default (shared), default(shared) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'default' clause}}
for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target teams distribute default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target teams distribute default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -36,6 +36,11 @@ int main(int argc, char **argv) {
++x;
++y;
}
+#pragma omp target teams distribute default(private) // expected-error {{data-sharing attribute 'private' in 'default' clause requires OpenMP version 5.1 or above}}
+ for (int i = 0; i < 200; i++) {
+ ++x;
+ ++y;
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
index 2fe7931369618..d00668e0b8ce5 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
@@ -16,15 +16,15 @@ static int x = 0;
int main(int argc, char **argv) {
#pragma omp target teams distribute parallel for default // expected-error {{expected '(' after 'default'}}
for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams distribute parallel for default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target teams distribute parallel for default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int i=0; i<200; i++) foo();
#pragma omp target teams distribute parallel for default (shared), default(shared) // expected-error {{directive '#pragma omp target teams distribute parallel for' cannot contain more than one 'default' clause}}
for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target teams distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -36,6 +36,11 @@ int main(int argc, char **argv) {
++x;
++y;
}
+#pragma omp target teams distribute parallel for default(private) // expected-error {{data-sharing attribute 'private' in 'default' clause requires OpenMP version 5.1 or above}}
+ for (int i = 0; i < 200; i++) {
+ ++x;
+ ++y;
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
index e5ff856222501..5eb702dc55530 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
@@ -17,10 +17,10 @@ int main(int argc, char **argv) {
#pragma omp target teams distribute parallel for simd default // expected-error {{expected '(' after 'default'}}
for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams distribute parallel for simd default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for simd default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target teams distribute parallel for simd default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -29,7 +29,7 @@ int main(int argc, char **argv) {
#pragma omp target teams distribute parallel for simd default (shared), default(shared) // expected-error {{directive '#pragma omp target teams distribute parallel for simd' cannot contain more than one 'default' clause}}
for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target teams distribute parallel for simd default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -41,6 +41,11 @@ int main(int argc, char **argv) {
++x;
++y;
}
+#pragma omp target teams distribute parallel for simd default(private) // expected-error {{data-sharing attribute 'private' in 'default' clause requires OpenMP version 5.1 or above}}
+ for (int i = 0; i < argc; ++i) {
+ ++x;
+ ++y;
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/task_default_messages.cpp b/clang/test/OpenMP/task_default_messages.cpp
index 8b6809ee05d56..820e593a110ad 100644
--- a/clang/test/OpenMP/task_default_messages.cpp
+++ b/clang/test/OpenMP/task_default_messages.cpp
@@ -15,11 +15,11 @@ static int x = 0;
int main(int argc, char **argv) {
#pragma omp task default // expected-error {{expected '(' after 'default'}}
-#pragma omp task default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-#pragma omp task default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp task default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp task default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
#pragma omp task default(none // expected-error {{expected ')'}} expected-note {{to match this '('}}
#pragma omp task default(shared), default(shared) // expected-error {{directive '#pragma omp task' cannot contain more than one 'default' clause}}
-#pragma omp task default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp task default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
foo();
#pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -35,6 +35,11 @@ int main(int argc, char **argv) {
++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
}
+#pragma omp task default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
+ {
+ ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+ ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+ }
#endif
return 0;
}
diff --git a/clang/test/OpenMP/teams_default_messages.cpp b/clang/test/OpenMP/teams_default_messages.cpp
index b117ef4948a0f..bd56ea88ca745 100644
--- a/clang/test/OpenMP/teams_default_messages.cpp
+++ b/clang/test/OpenMP/teams_default_messages.cpp
@@ -18,10 +18,10 @@ int main(int argc, char **argv) {
#pragma omp teams default // expected-error {{expected '(' after 'default'}}
foo();
#pragma omp target
-#pragma omp teams default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
foo();
#pragma omp target
-#pragma omp teams default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp teams default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
foo();
#pragma omp target
#pragma omp teams default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
#pragma omp teams default (shared), default(shared) // expected-error {{directive '#pragma omp teams' cannot contain more than one 'default' clause}}
foo();
#pragma omp target
-#pragma omp teams default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp teams default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
foo();
#pragma omp target
@@ -49,6 +49,12 @@ int main(int argc, char **argv) {
++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
}
+#pragma omp target
+#pragma omp teams default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
+ {
+ ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+ ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+ }
#endif
return 0;
}
diff --git a/clang/test/OpenMP/teams_distribute_default_messages.cpp b/clang/test/OpenMP/teams_distribute_default_messages.cpp
index 1d5fd40c53a6b..c485093f76b9f 100644
--- a/clang/test/OpenMP/teams_distribute_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_default_messages.cpp
@@ -18,10 +18,10 @@ int main(int argc, char **argv) {
#pragma omp teams distribute default // expected-error {{expected '(' after 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp teams distribute default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
#pragma omp teams distribute default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
#pragma omp teams distribute default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute' cannot contain more than one 'default' clause}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp teams distribute default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
@@ -44,6 +44,12 @@ int main(int argc, char **argv) {
++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
}
+#pragma omp target
+#pragma omp teams distribute default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
+ for (int i = 0; i < 200; i++) {
+ ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+ ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp b/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
index 3a414543be806..170087f064388 100644
--- a/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
@@ -18,10 +18,10 @@ int main(int argc, char **argv) {
#pragma omp teams distribute parallel for default // expected-error {{expected '(' after 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute parallel for default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
#pragma omp teams distribute parallel for default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
#pragma omp teams distribute parallel for default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'default' clause}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
@@ -44,6 +44,12 @@ int main(int argc, char **argv) {
++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
}
+#pragma omp target
+#pragma omp teams distribute parallel for default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
+ for (int i = 0; i < 200; i++) {
+ ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+ ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
index ce7f35b479592..6240f95173c42 100644
--- a/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
@@ -18,10 +18,10 @@ int main(int argc, char **argv) {
#pragma omp teams distribute parallel for simd default // expected-error {{expected '(' after 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute parallel for simd default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for simd default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
#pragma omp teams distribute parallel for simd default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
#pragma omp teams distribute parallel for simd default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'default' clause}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
@@ -43,6 +43,11 @@ int main(int argc, char **argv) {
++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
}
+#pragma omp teams distribute parallel for default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
+ for (int i = 0; i < 200; i++) {
+ ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+ ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+ }
#endif
return 0;
diff --git a/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp b/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
index 11f5d1cd1fc8f..ffc103671e69f 100644
--- a/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
@@ -14,10 +14,10 @@ int main(int argc, char **argv) {
#pragma omp teams distribute simd default // expected-error {{expected '(' after 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute simd default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp teams distribute simd default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
#pragma omp teams distribute simd default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -26,7 +26,7 @@ int main(int argc, char **argv) {
#pragma omp teams distribute simd default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute simd' cannot contain more than one 'default' clause}}
for (int i=0; i<200; i++) foo();
#pragma omp target
-#pragma omp teams distribute simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp teams distribute simd default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
for (int i=0; i<200; i++) foo();
#pragma omp target
@@ -43,5 +43,15 @@ int main(int argc, char **argv) {
for (int i = 0; i < 200; i++)
++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+#pragma omp target
+#pragma omp teams distribute simd default(private) // expected-note {{explicit data sharing attribute requested here}}
+ for (int i = 0; i < 200; i++)
+ ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+
+#pragma omp target
+#pragma omp teams distribute simd default(private) // expected-note {{explicit data sharing attribute requested here}}
+ for (int i = 0; i < 200; i++)
+ ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+
return 0;
}
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index d1c9790401f02..7811402199ccb 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -4122,12 +4122,19 @@ void x(int x) {
})";
EXPECT_TRUE(notMatchesWithOpenMP51(Source4, Matcher));
- const std::string Source5 = R"(
+ StringRef Source5 = R"(
+void x(int x) {
+#pragma omp parallel default(private)
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP51(Source5, Matcher));
+
+ const std::string Source6 = R"(
void x(int x) {
#pragma omp parallel num_threads(x)
;
})";
- EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
+ EXPECT_TRUE(notMatchesWithOpenMP(Source6, Matcher));
}
TEST_P(ASTMatchersTest, OMPDefaultClause_IsSharedKind) {
@@ -4168,12 +4175,19 @@ void x(int x) {
})";
EXPECT_TRUE(notMatchesWithOpenMP51(Source4, Matcher));
- const std::string Source5 = R"(
+ StringRef Source5 = R"(
+void x(int x) {
+#pragma omp parallel default(private)
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP51(Source5, Matcher));
+
+ const std::string Source6 = R"(
void x(int x) {
#pragma omp parallel num_threads(x)
;
})";
- EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
+ EXPECT_TRUE(notMatchesWithOpenMP(Source6, Matcher));
}
TEST(OMPDefaultClause, isFirstPrivateKind) {
@@ -4216,10 +4230,70 @@ void x(int x) {
const std::string Source5 = R"(
void x(int x) {
+#pragma omp parallel default(private)
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP51(Source5, Matcher));
+
+ const std::string Source6 = R"(
+void x(int x) {
#pragma omp parallel num_threads(x)
;
})";
- EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
+ EXPECT_TRUE(notMatchesWithOpenMP(Source6, Matcher));
+}
+
+TEST(OMPDefaultClause, istPrivateKind) {
+ auto Matcher =
+ ompExecutableDirective(hasAnyClause(ompDefaultClause(isPrivateKind())));
+
+ const std::string Source0 = R"(
+void x() {
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(Source0, Matcher));
+
+ const std::string Source1 = R"(
+void x() {
+#pragma omp parallel
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(Source1, Matcher));
+
+ const std::string Source2 = R"(
+void x() {
+#pragma omp parallel default(shared)
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(Source2, Matcher));
+
+ const std::string Source3 = R"(
+void x() {
+#pragma omp parallel default(none)
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(Source3, Matcher));
+
+ const std::string Source4 = R"(
+void x(int x) {
+#pragma omp parallel default(firstprivate)
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP51(Source4, Matcher));
+
+ const std::string Source5 = R"(
+void x(int x) {
+#pragma omp parallel default(private)
+;
+})";
+ EXPECT_TRUE(matchesWithOpenMP51(Source5, Matcher));
+
+ const std::string Source6 = R"(
+void x(int x) {
+#pragma omp parallel num_threads(x)
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(Source6, Matcher));
}
TEST_P(ASTMatchersTest, OMPExecutableDirective_IsAllowedToContainClauseKind) {
@@ -4261,24 +4335,31 @@ void x() {
EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
StringRef Source5 = R"(
+void x() {
+#pragma omp parallel default(private)
+;
+})";
+ EXPECT_TRUE(matchesWithOpenMP51(Source5, Matcher));
+
+ StringRef Source6 = R"(
void x(int x) {
#pragma omp parallel num_threads(x)
;
})";
- EXPECT_TRUE(matchesWithOpenMP(Source5, Matcher));
+ EXPECT_TRUE(matchesWithOpenMP(Source6, Matcher));
- StringRef Source6 = R"(
+ StringRef Source7 = R"(
void x() {
#pragma omp taskyield
})";
- EXPECT_TRUE(notMatchesWithOpenMP(Source6, Matcher));
+ EXPECT_TRUE(notMatchesWithOpenMP(Source7, Matcher));
- StringRef Source7 = R"(
+ StringRef Source8 = R"(
void x() {
#pragma omp task
;
})";
- EXPECT_TRUE(matchesWithOpenMP(Source7, Matcher));
+ EXPECT_TRUE(matchesWithOpenMP(Source8, Matcher));
}
TEST_P(ASTMatchersTest, HasAnyBase_DirectBase) {
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index 2f18e8c615c06..0106fc444fac7 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -1032,6 +1032,7 @@ __OMP_CANCEL_KIND(taskgroup, 4)
__OMP_DEFAULT_KIND(none)
__OMP_DEFAULT_KIND(shared)
+__OMP_DEFAULT_KIND(private)
__OMP_DEFAULT_KIND(firstprivate)
__OMP_DEFAULT_KIND(unknown)
More information about the cfe-commits
mailing list