From 3568e530bf06790b2d8e79cec3bfd46811699693 Mon Sep 17 00:00:00 2001 From: Arpith Chacko Jacob Date: Mon, 1 Feb 2016 16:32:47 +0000 Subject: [PATCH] [OpenMP] Prevent nesting of target constructs within target code execution regions. Summary: This patch enhances Sema to check for the following restriction: OpenMP 4.5 [2.17 Nesting of Regions] If a target, target update, target data, target enter data, or target exit data construct is encountered during execution of a target region, the behavior is unspecified. Reviewers: ABataev Differential Revision: http://reviews.llvm.org/D16758 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259366 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/OpenMPKinds.h | 15 +++- lib/Basic/OpenMPKinds.cpp | 11 ++- lib/Sema/SemaOpenMP.cpp | 50 +++++++++---- test/OpenMP/distribute_private_messages.cpp | 17 +++-- test/OpenMP/nesting_of_regions.cpp | 52 ++++++------- test/OpenMP/target_data_device_messages.cpp | 4 +- test/OpenMP/target_device_messages.cpp | 13 +++- test/OpenMP/target_if_messages.cpp | 33 +++++++++ test/OpenMP/target_messages.cpp | 1 + .../target_parallel_default_messages.cpp | 6 ++ .../target_parallel_device_messages.cpp | 13 +++- .../target_parallel_firstprivate_messages.cpp | 20 +++++ test/OpenMP/target_parallel_if_messages.cpp | 39 ++++++++++ test/OpenMP/target_parallel_map_messages.cpp | 73 ++++++++++++++++++- test/OpenMP/target_parallel_messages.cpp | 1 + .../target_parallel_num_threads_messages.cpp | 21 ++++++ .../target_parallel_private_messages.cpp | 54 ++++++++++++-- .../target_parallel_proc_bind_messages.cpp | 6 ++ .../target_parallel_reduction_messages.cpp | 14 +++- .../target_parallel_shared_messages.cpp | 19 +++++ test/OpenMP/target_private_messages.cpp | 31 +++++++- test/OpenMP/teams_reduction_messages.cpp | 4 + 22 files changed, 423 insertions(+), 74 deletions(-) diff --git a/include/clang/Basic/OpenMPKinds.h b/include/clang/Basic/OpenMPKinds.h index 36dca49405..9a0bf5b60b 100644 --- a/include/clang/Basic/OpenMPKinds.h +++ b/include/clang/Basic/OpenMPKinds.h @@ -156,11 +156,20 @@ bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind); /// parallel', otherwise - false. bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind); -/// \brief Checks if the specified directive is a target-kind directive. +/// \brief Checks if the specified directive is a target code offload directive. /// \param DKind Specified directive. -/// \return true - the directive is a target-like directive like 'omp target', +/// \return true - the directive is a target code offload directive like +/// 'omp target', 'omp target parallel', 'omp target xxx' /// otherwise - false. -bool isOpenMPTargetDirective(OpenMPDirectiveKind DKind); +bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind); + +/// \brief Checks if the specified directive is a target data offload directive. +/// \param DKind Specified directive. +/// \return true - the directive is a target data offload directive like +/// 'omp target data', 'omp target update', 'omp target enter data', +/// 'omp target exit data' +/// otherwise - false. +bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind); /// \brief Checks if the specified directive is a teams-kind directive. /// \param DKind Specified directive. diff --git a/lib/Basic/OpenMPKinds.cpp b/lib/Basic/OpenMPKinds.cpp index e66a3e331e..523e603ee9 100644 --- a/lib/Basic/OpenMPKinds.cpp +++ b/lib/Basic/OpenMPKinds.cpp @@ -576,8 +576,15 @@ bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) { // TODO add next directives. } -bool clang::isOpenMPTargetDirective(OpenMPDirectiveKind DKind) { - return DKind == OMPD_target; // TODO add next directives. +bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) { + // TODO add next directives. + return DKind == OMPD_target || DKind == OMPD_target_parallel; +} + +bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) { + // TODO add target update directive check. + return DKind == OMPD_target_data || DKind == OMPD_target_enter_data || + DKind == OMPD_target_exit_data; } bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) { diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 577772301f..204e46a08d 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -809,7 +809,7 @@ bool Sema::IsOpenMPCapturedByRef(ValueDecl *D, auto DKind = DSAStack->getDirectiveForScope(RSI->TheScope); auto Ty = D->getType(); - if (isOpenMPTargetDirective(DKind)) { + if (isOpenMPTargetExecutionDirective(DKind)) { // This table summarizes how a given variable should be passed to the device // given its type and the clauses where it appears. This table is based on // the description in OpenMP 4.5 [2.10.4, target Construct] and @@ -907,7 +907,7 @@ bool Sema::IsOpenMPCapturedDecl(ValueDecl *D) { DSAStack->hasDirective( [](OpenMPDirectiveKind K, const DeclarationNameInfo &DNI, SourceLocation Loc) -> bool { - return isOpenMPTargetDirective(K); + return isOpenMPTargetExecutionDirective(K); }, false)) { return true; @@ -944,7 +944,8 @@ bool Sema::isOpenMPTargetCapturedDecl(ValueDecl *D, unsigned Level) { auto *VD = dyn_cast(D); return VD && !VD->hasLocalStorage() && - DSAStack->hasExplicitDirective(isOpenMPTargetDirective, Level); + DSAStack->hasExplicitDirective(isOpenMPTargetExecutionDirective, + Level); } void Sema::DestroyDataSharingAttributesStack() { delete DSAStack; } @@ -2313,11 +2314,11 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | target | flush | * | // | target | ordered | * | // | target | atomic | * | - // | target | target | * | - // | target | target parallel | * | - // | target | target enter | * | + // | target | target | | + // | target | target parallel | | + // | target | target enter | | // | | data | | - // | target | target exit | * | + // | target | target exit | | // | | data | | // | target | teams | * | // | target | cancellation | | @@ -2347,11 +2348,11 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | target parallel | flush | * | // | target parallel | ordered | * | // | target parallel | atomic | * | - // | target parallel | target | * | - // | target parallel | target parallel | * | - // | target parallel | target enter | * | + // | target parallel | target | | + // | target parallel | target parallel | | + // | target parallel | target enter | | // | | data | | - // | target parallel | target exit | * | + // | target parallel | target exit | | // | | data | | // | target parallel | teams | | // | target parallel | cancellation | | @@ -2498,6 +2499,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // +------------------+-----------------+------------------------------------+ if (Stack->getCurScope()) { auto ParentRegion = Stack->getParentDirective(); + auto OffendingRegion = ParentRegion; bool NestingProhibited = false; bool CloseNesting = true; enum { @@ -2658,10 +2660,32 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, NestingProhibited = !isOpenMPTeamsDirective(ParentRegion); Recommend = ShouldBeInTeamsRegion; } + if (!NestingProhibited && + (isOpenMPTargetExecutionDirective(CurrentRegion) || + isOpenMPTargetDataManagementDirective(CurrentRegion))) { + // OpenMP 4.5 [2.17 Nesting of Regions] + // If a target, target update, target data, target enter data, or + // target exit data construct is encountered during execution of a + // target region, the behavior is unspecified. + OpenMPDirectiveKind PreviousTargetExecutionDirective; + NestingProhibited = Stack->hasDirective( + [&PreviousTargetExecutionDirective](OpenMPDirectiveKind K, + const DeclarationNameInfo &DNI, + SourceLocation Loc) -> bool { + if (isOpenMPTargetExecutionDirective(K)) { + PreviousTargetExecutionDirective = K; + return true; + } else + return false; + }, + false /* don't skip top directive */); + CloseNesting = false; + OffendingRegion = PreviousTargetExecutionDirective; + } if (NestingProhibited) { SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region) - << CloseNesting << getOpenMPDirectiveName(ParentRegion) << Recommend - << getOpenMPDirectiveName(CurrentRegion); + << CloseNesting << getOpenMPDirectiveName(OffendingRegion) + << Recommend << getOpenMPDirectiveName(CurrentRegion); return true; } } diff --git a/test/OpenMP/distribute_private_messages.cpp b/test/OpenMP/distribute_private_messages.cpp index 94ba4659c6..518b64d9e9 100644 --- a/test/OpenMP/distribute_private_messages.cpp +++ b/test/OpenMP/distribute_private_messages.cpp @@ -98,6 +98,7 @@ int main(int argc, char **argv) { #pragma omp target #pragma omp teams firstprivate(i) #pragma omp parallel private(i) + {} #pragma omp target #pragma omp teams reduction(+:i) #pragma omp distribute private(i) @@ -113,20 +114,20 @@ int main(int argc, char **argv) { #pragma omp teams #pragma omp distribute firstprivate(i) for (int k = 0; k < 10; ++k) { - #pragma omp target - #pragma omp teams firstprivate(i) - #pragma omp distribute private(i) - for (int x = 0; x < 10; ++x) foo(); } #pragma omp target + #pragma omp teams firstprivate(i) + #pragma omp distribute private(i) + for (int x = 0; x < 10; ++x) foo(); + #pragma omp target #pragma omp teams reduction(+:i) #pragma omp distribute for (int k = 0; k < 10; ++k) { - #pragma omp target - #pragma omp teams reduction(+:i) - #pragma omp distribute private(i) - for (int x = 0; x < 10; ++x) foo(); } + #pragma omp target + #pragma omp teams reduction(+:i) + #pragma omp distribute private(i) + for (int x = 0; x < 10; ++x) foo(); return 0; } diff --git a/test/OpenMP/nesting_of_regions.cpp b/test/OpenMP/nesting_of_regions.cpp index ebab809c56..4fa6cac01a 100644 --- a/test/OpenMP/nesting_of_regions.cpp +++ b/test/OpenMP/nesting_of_regions.cpp @@ -2666,12 +2666,12 @@ void foo() { } #pragma omp target { -#pragma omp target +#pragma omp target // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target { -#pragma omp target parallel +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target @@ -2699,11 +2699,11 @@ void foo() { } #pragma omp target { -#pragma omp target enter data map(to: a) +#pragma omp target enter data map(to: a) // expected-error {{region cannot be nested inside 'target' region}} } #pragma omp target { -#pragma omp target exit data map(from: a) +#pragma omp target exit data map(from: a) // expected-error {{region cannot be nested inside 'target' region}} } // TARGET PARALLEL DIRECTIVE @@ -2796,12 +2796,12 @@ void foo() { } #pragma omp target parallel { -#pragma omp target +#pragma omp target // expected-error {{region cannot be nested inside 'target parallel' region}} ++a; } #pragma omp target parallel { -#pragma omp target parallel +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target parallel' region}} ++a; } #pragma omp target parallel @@ -2829,11 +2829,11 @@ void foo() { } #pragma omp target parallel { -#pragma omp target enter data map(to: a) +#pragma omp target enter data map(to: a) // expected-error {{region cannot be nested inside 'target parallel' region}} } #pragma omp target parallel { -#pragma omp target exit data map(from: a) +#pragma omp target exit data map(from: a) // expected-error {{region cannot be nested inside 'target parallel' region}} } // TEAMS DIRECTIVE @@ -2952,7 +2952,7 @@ void foo() { #pragma omp target #pragma omp teams { -#pragma omp target parallel +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target @@ -3337,28 +3337,28 @@ void foo() { #pragma omp teams #pragma omp distribute for (int i = 0; i < 10; ++i) { -#pragma omp target +#pragma omp target // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target #pragma omp teams #pragma omp distribute for (int i = 0; i < 10; ++i) { -#pragma omp target parallel +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target #pragma omp teams #pragma omp distribute for (int i = 0; i < 10; ++i) { -#pragma omp target enter data map(to: a) +#pragma omp target enter data map(to: a) // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target #pragma omp teams #pragma omp distribute for (int i = 0; i < 10; ++i) { -#pragma omp target exit data map(from: a) +#pragma omp target exit data map(from: a) // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target @@ -5807,21 +5807,21 @@ void foo() { } #pragma omp target { -#pragma omp target +#pragma omp target // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target { -#pragma omp target parallel +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target { -#pragma omp target enter data map(to: a) +#pragma omp target enter data map(to: a) // expected-error {{region cannot be nested inside 'target' region}} } #pragma omp target { -#pragma omp target exit data map(from: a) +#pragma omp target exit data map(from: a) // expected-error {{region cannot be nested inside 'target' region}} } #pragma omp target { @@ -5937,12 +5937,12 @@ void foo() { } #pragma omp target parallel { -#pragma omp target +#pragma omp target // expected-error {{region cannot be nested inside 'target parallel' region}} ++a; } #pragma omp target parallel { -#pragma omp target parallel +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target parallel' region}} ++a; } #pragma omp target parallel @@ -5970,11 +5970,11 @@ void foo() { } #pragma omp target parallel { -#pragma omp target enter data map(to: a) +#pragma omp target enter data map(to: a) // expected-error {{region cannot be nested inside 'target parallel' region}} } #pragma omp target parallel { -#pragma omp target exit data map(from: a) +#pragma omp target exit data map(from: a) // expected-error {{region cannot be nested inside 'target parallel' region}} } // TEAMS DIRECTIVE @@ -6093,7 +6093,7 @@ void foo() { #pragma omp target #pragma omp teams { -#pragma omp target parallel +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target @@ -6477,14 +6477,14 @@ void foo() { #pragma omp teams #pragma omp distribute for (int i = 0; i < 10; ++i) { -#pragma omp target +#pragma omp target // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target #pragma omp teams #pragma omp distribute for (int i = 0; i < 10; ++i) { -#pragma omp target parallel +#pragma omp target parallel // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target @@ -6499,14 +6499,14 @@ void foo() { #pragma omp teams #pragma omp distribute for (int i = 0; i < 10; ++i) { -#pragma omp target enter data map(to: a) +#pragma omp target enter data map(to: a) // expected-error {{region cannot be nested inside 'target' region}} ++a; } #pragma omp target #pragma omp teams #pragma omp distribute for (int i = 0; i < 10; ++i) { -#pragma omp target exit data map(from: a) +#pragma omp target exit data map(from: a) // expected-error {{region cannot be nested inside 'target' region}} ++a; } } diff --git a/test/OpenMP/target_data_device_messages.cpp b/test/OpenMP/target_data_device_messages.cpp index a46afee035..9ed7a54b43 100644 --- a/test/OpenMP/target_data_device_messages.cpp +++ b/test/OpenMP/target_data_device_messages.cpp @@ -21,8 +21,8 @@ int main(int argc, char **argv) { #pragma omp target data map(to: a) device (argc), device (argc+1) // expected-error {{directive '#pragma omp target data' cannot contain more than one 'device' clause}} #pragma omp target data map(to: a) device (S1) // expected-error {{'S1' does not refer to a value}} #pragma omp target data map(to: a) device (-2) // expected-error {{argument to 'device' clause must be a non-negative integer value}} - #pragma omp target map(to: a) device (-10u) - #pragma omp target map(to: a) device (3.14) // expected-error {{expression must have integral or unscoped enumeration type, not 'double'}} + #pragma omp target data map(to: a) device (-10u) + #pragma omp target data map(to: a) device (3.14) // expected-error {{expression must have integral or unscoped enumeration type, not 'double'}} foo(); return 0; diff --git a/test/OpenMP/target_device_messages.cpp b/test/OpenMP/target_device_messages.cpp index fb0f2defa4..3befcd6908 100644 --- a/test/OpenMP/target_device_messages.cpp +++ b/test/OpenMP/target_device_messages.cpp @@ -11,16 +11,27 @@ struct S1; // expected-note {{declared here}} int main(int argc, char **argv) { #pragma omp target device // expected-error {{expected '(' after 'device'}} + foo(); #pragma omp target device ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target device () // expected-error {{expected expression}} + foo(); #pragma omp target device (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target device (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} -#pragma omp target device (argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + foo(); + #pragma omp target device (argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + foo(); #pragma omp target device (argc + argc) + foo(); #pragma omp target device (argc), device (argc+1) // expected-error {{directive '#pragma omp target' cannot contain more than one 'device' clause}} + foo(); #pragma omp target device (S1) // expected-error {{'S1' does not refer to a value}} + foo(); #pragma omp target device (-2) // expected-error {{argument to 'device' clause must be a non-negative integer value}} + foo(); #pragma omp target device (-10u) + foo(); #pragma omp target device (3.14) // expected-error {{expression must have integral or unscoped enumeration type, not 'double'}} foo(); diff --git a/test/OpenMP/target_if_messages.cpp b/test/OpenMP/target_if_messages.cpp index 4ee7302282..189256e60f 100644 --- a/test/OpenMP/target_if_messages.cpp +++ b/test/OpenMP/target_if_messages.cpp @@ -12,21 +12,37 @@ struct S1; // expected-note {{declared here}} template // expected-note {{declared here}} int tmain(T argc, S **argv) { #pragma omp target if // expected-error {{expected '(' after 'if'}} + foo(); #pragma omp target if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if () // expected-error {{expected expression}} + foo(); #pragma omp target if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} + foo(); #pragma omp target if (argc > 0 ? argv[1] : argv[2]) + foo(); #pragma omp target if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause}} + foo(); #pragma omp target if (S) // expected-error {{'S' does not refer to a value}} + foo(); #pragma omp target if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if(argc) + foo(); #pragma omp target if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if(target : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if(target : argc) + foo(); #pragma omp target if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target'}} + foo(); #pragma omp target if(target : argc) if (target:argc) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause with 'target' name modifier}} + foo(); #pragma omp target if(target : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} foo(); @@ -35,22 +51,39 @@ int tmain(T argc, S **argv) { int main(int argc, char **argv) { #pragma omp target if // expected-error {{expected '(' after 'if'}} + foo(); #pragma omp target if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if () // expected-error {{expected expression}} + foo(); #pragma omp target if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} + foo(); #pragma omp target if (argc > 0 ? argv[1] : argv[2]) + foo(); #pragma omp target if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause}} + foo(); #pragma omp target if (S1) // expected-error {{'S1' does not refer to a value}} + foo(); #pragma omp target if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if(target : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target if(target : argc) + foo(); #pragma omp target if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target'}} + foo(); #pragma omp target if(target : argc) if (target:argc) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause with 'target' name modifier}} + foo(); #pragma omp target if(target : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} foo(); diff --git a/test/OpenMP/target_messages.cpp b/test/OpenMP/target_messages.cpp index 86a91838ce..361da5f381 100644 --- a/test/OpenMP/target_messages.cpp +++ b/test/OpenMP/target_messages.cpp @@ -21,6 +21,7 @@ int main(int argc, char **argv) { #pragma omp target } // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} foo(); #pragma omp target + foo(); // expected-warning@+1 {{extra tokens at the end of '#pragma omp target' are ignored}} #pragma omp target unknown() foo(); diff --git a/test/OpenMP/target_parallel_default_messages.cpp b/test/OpenMP/target_parallel_default_messages.cpp index 7d2990b780..40f31b8484 100644 --- a/test/OpenMP/target_parallel_default_messages.cpp +++ b/test/OpenMP/target_parallel_default_messages.cpp @@ -4,10 +4,15 @@ void foo(); 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' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel default () // expected-error {{expected 'none' or 'shared' 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' or 'shared' in OpenMP clause 'default'}} foo(); @@ -15,6 +20,7 @@ int main(int argc, char **argv) { ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} #pragma omp target parallel default(none) + foo(); #pragma omp target parallel default(shared) ++argc; return 0; diff --git a/test/OpenMP/target_parallel_device_messages.cpp b/test/OpenMP/target_parallel_device_messages.cpp index 7c03975988..6c8d4c2e43 100644 --- a/test/OpenMP/target_parallel_device_messages.cpp +++ b/test/OpenMP/target_parallel_device_messages.cpp @@ -11,16 +11,27 @@ struct S1; // expected-note {{declared here}} int main(int argc, char **argv) { #pragma omp target parallel device // expected-error {{expected '(' after 'device'}} + foo(); #pragma omp target parallel device ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel device () // expected-error {{expected expression}} + foo(); #pragma omp target parallel device (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel device (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} -#pragma omp target parallel device (argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + foo(); + #pragma omp target parallel device (argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + foo(); #pragma omp target parallel device (argc + argc) + foo(); #pragma omp target parallel device (argc), device (argc+1) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'device' clause}} + foo(); #pragma omp target parallel device (S1) // expected-error {{'S1' does not refer to a value}} + foo(); #pragma omp target parallel device (-2) // expected-error {{argument to 'device' clause must be a non-negative integer value}} + foo(); #pragma omp target parallel device (-10u) + foo(); #pragma omp target parallel device (3.14) // expected-error {{expression must have integral or unscoped enumeration type, not 'double'}} foo(); diff --git a/test/OpenMP/target_parallel_firstprivate_messages.cpp b/test/OpenMP/target_parallel_firstprivate_messages.cpp index ee0f64ec71..dd6825aa25 100644 --- a/test/OpenMP/target_parallel_firstprivate_messages.cpp +++ b/test/OpenMP/target_parallel_firstprivate_messages.cpp @@ -64,27 +64,47 @@ int main(int argc, char **argv) { int &j = i; static int m; #pragma omp target parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}} + foo(); #pragma omp target parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel firstprivate () // expected-error {{expected expression}} + foo(); #pragma omp target parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + foo(); #pragma omp target parallel firstprivate (argc) + foo(); #pragma omp target parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}} + foo(); #pragma omp target parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} + foo(); #pragma omp target parallel firstprivate (argv[1]) // expected-error {{expected variable name}} + foo(); #pragma omp target parallel firstprivate(ba) + foo(); #pragma omp target parallel firstprivate(ca) + foo(); #pragma omp target parallel firstprivate(da) + foo(); #pragma omp target parallel firstprivate(S2::S2s) + foo(); #pragma omp target parallel firstprivate(S2::S2sc) + foo(); #pragma omp target parallel firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} + foo(); #pragma omp target parallel firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}} + foo(); #pragma omp target parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}} foo(); #pragma omp target parallel shared(i) + foo(); #pragma omp target parallel firstprivate(i) + foo(); #pragma omp target parallel firstprivate(j) + foo(); #pragma omp target parallel firstprivate(m) foo(); diff --git a/test/OpenMP/target_parallel_if_messages.cpp b/test/OpenMP/target_parallel_if_messages.cpp index 00e52d17ad..e22eb8150a 100644 --- a/test/OpenMP/target_parallel_if_messages.cpp +++ b/test/OpenMP/target_parallel_if_messages.cpp @@ -12,25 +12,45 @@ struct S1; // expected-note {{declared here}} template // expected-note {{declared here}} int tmain(T argc, S **argv) { #pragma omp target parallel if // expected-error {{expected '(' after 'if'}} + foo(); #pragma omp target parallel if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if () // expected-error {{expected expression}} + foo(); #pragma omp target parallel if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); #pragma omp target parallel if (argc > 0 ? argv[1] : argv[2]) + foo(); #pragma omp target parallel if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause}} + foo(); #pragma omp target parallel if (S) // expected-error {{'S' does not refer to a value}} + foo(); #pragma omp target parallel if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if(argc) + foo(); #pragma omp target parallel if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if(target : argc) + foo(); #pragma omp target parallel if(parallel : argc) + foo(); #pragma omp target parallel if(target : argc) if(parallel : argc) + foo(); #pragma omp target parallel if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel'}} + foo(); #pragma omp target parallel if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'target' name modifier}} + foo(); #pragma omp target parallel if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'parallel' name modifier}} + foo(); #pragma omp target parallel if(target : argc) if (argc) // expected-error {{expected 'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}} + foo(); #pragma omp target parallel if(target : argc) if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} expected-note {{previous clause with directive name modifier specified here}} foo(); @@ -39,24 +59,43 @@ int tmain(T argc, S **argv) { int main(int argc, char **argv) { #pragma omp target parallel if // expected-error {{expected '(' after 'if'}} + foo(); #pragma omp target parallel if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if () // expected-error {{expected expression}} + foo(); #pragma omp target parallel if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); #pragma omp target parallel if (argc > 0 ? argv[1] : argv[2]) + foo(); #pragma omp target parallel if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause}} + foo(); #pragma omp target parallel if (S1) // expected-error {{'S1' does not refer to a value}} + foo(); #pragma omp target parallel if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel if(parallel : argc) + foo(); #pragma omp target parallel if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel'}} + foo(); #pragma omp target parallel if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'target' name modifier}} + foo(); #pragma omp target parallel if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'if' clause with 'parallel' name modifier}} + foo(); #pragma omp target parallel if(target : argc) if (argc) // expected-error {{expected 'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}} + foo(); #pragma omp target parallel if(target : argc) if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} expected-note {{previous clause with directive name modifier specified here}} foo(); diff --git a/test/OpenMP/target_parallel_map_messages.cpp b/test/OpenMP/target_parallel_map_messages.cpp index 0fbf992b27..9d1be5ccae 100644 --- a/test/OpenMP/target_parallel_map_messages.cpp +++ b/test/OpenMP/target_parallel_map_messages.cpp @@ -65,13 +65,21 @@ T tmain(T argc) { #pragma omp target parallel map // expected-error {{expected '(' after 'map'}} + foo(); #pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} + foo(); #pragma omp target parallel map() // expected-error {{expected expression}} + foo(); #pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} + foo(); #pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} + foo(); #pragma omp target parallel map(to:) // expected-error {{expected expression}} + foo(); #pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} + foo(); #pragma omp target parallel map(x) foo(); #pragma omp target parallel map(tofrom: t[:I]) @@ -97,38 +105,62 @@ T tmain(T argc) { #pragma omp target parallel map(to, x) foo(); #pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} + foo(); #pragma omp target parallel map(tofrom: argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} + foo(); #pragma omp target parallel map(argc) + foo(); #pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}} + foo(); #pragma omp target parallel map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}} + foo(); #pragma omp target parallel map(ba) // expected-error 2 {{type 'S2' is not mappable to target}} + foo(); #pragma omp target parallel map(ca) + foo(); #pragma omp target parallel map(da) + foo(); #pragma omp target parallel map(S2::S2s) + foo(); #pragma omp target parallel map(S2::S2sc) + foo(); #pragma omp target parallel map(e, g) + foo(); #pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in map clause}} + foo(); #pragma omp target parallel map(k), map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} + foo(); #pragma omp target parallel map(k), map(k[:5]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} expected-note 2 {{used here}} foo(); #pragma omp target parallel map(da) + foo(); #pragma omp target parallel map(da[:4]) foo(); -#pragma omp target parallel map(k, j, l) // expected-note 2 {{used here}} +#pragma omp target data map(k, j, l) // expected-note 2 {{used here}} #pragma omp target parallel map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} + foo(); #pragma omp target parallel map(j) + foo(); #pragma omp target parallel map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} foo(); -#pragma omp target parallel map(k[:4], j, l[:5]) // expected-note 4 {{used here}} +#pragma omp target data map(k[:4], j, l[:5]) // expected-note 4 {{used here}} +{ #pragma omp target parallel map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} + foo(); #pragma omp target parallel map(j) + foo(); #pragma omp target parallel map(l) // expected-error 2 {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}} foo(); +} #pragma omp target parallel map(always, tofrom: x) + foo(); #pragma omp target parallel map(always: x) // expected-error {{missing map type}} + foo(); #pragma omp target parallel map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always'}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} + foo(); #pragma omp target parallel map(always, tofrom: always, tofrom, x) + foo(); #pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} foo(); @@ -148,13 +180,21 @@ int main(int argc, char **argv) { int to, tofrom, always; const int (&l)[5] = da; #pragma omp target parallel map // expected-error {{expected '(' after 'map'}} + foo(); #pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} + foo(); #pragma omp target parallel map() // expected-error {{expected expression}} + foo(); #pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} + foo(); #pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} + foo(); #pragma omp target parallel map(to:) // expected-error {{expected expression}} + foo(); #pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} + foo(); #pragma omp target parallel map(x) foo(); #pragma omp target parallel map(to: x) @@ -166,39 +206,64 @@ int main(int argc, char **argv) { #pragma omp target parallel map(to, x) foo(); #pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} + foo(); #pragma omp target parallel map(tofrom: argc > 0 ? argv[1] : argv[2]) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}} + foo(); #pragma omp target parallel map(argc) + foo(); #pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}} + foo(); #pragma omp target parallel map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}} + foo(); #pragma omp target parallel map(argv[1]) + foo(); #pragma omp target parallel map(ba) // expected-error 2 {{type 'S2' is not mappable to target}} + foo(); #pragma omp target parallel map(ca) + foo(); #pragma omp target parallel map(da) + foo(); #pragma omp target parallel map(S2::S2s) + foo(); #pragma omp target parallel map(S2::S2sc) + foo(); #pragma omp target parallel map(e, g) + foo(); #pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in map clause}} + foo(); #pragma omp target parallel map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} + foo(); #pragma omp target parallel map(k), map(k[:5]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} foo(); #pragma omp target parallel map(da) + foo(); #pragma omp target parallel map(da[:4]) foo(); -#pragma omp target parallel map(k, j, l) // expected-note {{used here}} +#pragma omp target data map(k, j, l) // expected-note {{used here}} #pragma omp target parallel map(k[:4]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} + foo(); #pragma omp target parallel map(j) + foo(); #pragma omp target parallel map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}} foo(); -#pragma omp target parallel map(k[:4], j, l[:5]) // expected-note 2 {{used here}} +#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}} +{ #pragma omp target parallel map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}} + foo(); #pragma omp target parallel map(j) + foo(); #pragma omp target parallel map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}} foo(); +} #pragma omp target parallel map(always, tofrom: x) + foo(); #pragma omp target parallel map(always: x) // expected-error {{missing map type}} + foo(); #pragma omp target parallel map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always'}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} + foo(); #pragma omp target parallel map(always, tofrom: always, tofrom, x) + foo(); #pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} foo(); diff --git a/test/OpenMP/target_parallel_messages.cpp b/test/OpenMP/target_parallel_messages.cpp index 65525512fa..6fc83ecdfe 100644 --- a/test/OpenMP/target_parallel_messages.cpp +++ b/test/OpenMP/target_parallel_messages.cpp @@ -24,6 +24,7 @@ int main(int argc, char **argv) { #pragma omp target parallel } // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} foo(); #pragma omp target parallel + foo(); // expected-warning@+1 {{extra tokens at the end of '#pragma omp target parallel' are ignored}} #pragma omp target parallel unknown() foo(); diff --git a/test/OpenMP/target_parallel_num_threads_messages.cpp b/test/OpenMP/target_parallel_num_threads_messages.cpp index 4de151fa4c..95797caf29 100644 --- a/test/OpenMP/target_parallel_num_threads_messages.cpp +++ b/test/OpenMP/target_parallel_num_threads_messages.cpp @@ -14,16 +14,27 @@ struct S1; // expected-note {{declared here}} template // expected-note {{declared here}} T tmain(T argc, S **argv) { #pragma omp target parallel num_threads // expected-error {{expected '(' after 'num_threads'}} + foo(); #pragma omp target parallel num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel num_threads () // expected-error {{expected expression}} + foo(); #pragma omp target parallel num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); #pragma omp target parallel num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}} + foo(); #pragma omp target parallel num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp target parallel' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}} + foo(); #pragma omp target parallel num_threads (S) // expected-error {{'S' does not refer to a value}} + foo(); #pragma omp target parallel num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}} + foo(); #pragma omp target parallel num_threads (argc) + foo(); #pragma omp target parallel num_threads (N) // expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}} + foo(); #pragma omp target parallel redef_num_threads (argc, argc) foo(); @@ -32,15 +43,25 @@ T tmain(T argc, S **argv) { int main(int argc, char **argv) { #pragma omp target parallel num_threads // expected-error {{expected '(' after 'num_threads'}} + foo(); #pragma omp target parallel num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel num_threads () // expected-error {{expected expression}} + foo(); #pragma omp target parallel num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}} + foo(); #pragma omp target parallel num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }} + foo(); #pragma omp target parallel num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp target parallel' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}} + foo(); #pragma omp target parallel num_threads (S1) // expected-error {{'S1' does not refer to a value}} + foo(); #pragma omp target parallel num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} + foo(); #pragma omp target parallel num_threads (num_threads(tmain(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} + foo(); #pragma omp target parallel redef_num_threads (argc, argc) foo(); diff --git a/test/OpenMP/target_parallel_private_messages.cpp b/test/OpenMP/target_parallel_private_messages.cpp index 47eae41a2c..fabd37d4b3 100644 --- a/test/OpenMP/target_parallel_private_messages.cpp +++ b/test/OpenMP/target_parallel_private_messages.cpp @@ -61,28 +61,47 @@ int foomain(I argc, C **argv) { I i; I &j = i; #pragma omp target parallel private // expected-error {{expected '(' after 'private'}} +{} #pragma omp target parallel private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target parallel private() // expected-error {{expected expression}} +{} #pragma omp target parallel private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target parallel private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target parallel private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} +{} #pragma omp target parallel private(argc argv) // expected-error {{expected ',' or ')' in 'private' clause}} +{} #pragma omp target parallel private(argc) +{} #pragma omp target parallel private(S1) // expected-error {{'S1' does not refer to a value}} +{} #pragma omp target parallel private(a, b) // expected-error {{private variable with incomplete type 'S1'}} +{} #pragma omp target parallel private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}} +{} #pragma omp target parallel private(argv[1]) // expected-error {{expected variable name}} +{} #pragma omp target parallel private(ba) +{} #pragma omp target parallel private(ca) // expected-error {{shared variable cannot be private}} +{} #pragma omp target parallel private(da) // expected-error {{shared variable cannot be private}} +{} #pragma omp target parallel private(S2::S2s) // expected-error {{shared variable cannot be private}} +{} #pragma omp target parallel private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} +{} #pragma omp target parallel private(threadvar, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}} + {} #pragma omp target parallel shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}} foo(); #pragma omp target parallel firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}} foo(); #pragma omp target parallel private(i) + {} #pragma omp target parallel private(j) foo(); #pragma omp parallel firstprivate(i) @@ -94,19 +113,21 @@ int foomain(I argc, C **argv) { #pragma omp target parallel private(m) // OK foo(); #pragma omp target parallel private(h) // expected-error {{threadprivate or thread local variable cannot be private}} +{} #pragma omp target parallel private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}} #pragma omp parallel { int v = 0; int i; -#pragma omp target parallel private(i) - {} } #pragma omp target parallel shared(i) +{} #pragma omp target parallel private(i) +{} #pragma omp target parallel private(j) +{} #pragma omp target parallel private(i) - {} +{} static int si; #pragma omp target parallel private(si) // OK {} @@ -127,28 +148,47 @@ int main(int argc, char **argv) { int i; int &j = i; #pragma omp target parallel private // expected-error {{expected '(' after 'private'}} +{} #pragma omp target parallel private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target parallel private() // expected-error {{expected expression}} +{} #pragma omp target parallel private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target parallel private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target parallel private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} +{} #pragma omp target parallel private(argc argv) // expected-error {{expected ',' or ')' in 'private' clause}} +{} #pragma omp target parallel private(argc) +{} #pragma omp target parallel private(S1) // expected-error {{'S1' does not refer to a value}} +{} #pragma omp target parallel private(a, b) // expected-error {{private variable with incomplete type 'S1'}} +{} #pragma omp target parallel private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}} +{} #pragma omp target parallel private(argv[1]) // expected-error {{expected variable name}} +{} #pragma omp target parallel private(ba) +{} #pragma omp target parallel private(ca) // expected-error {{shared variable cannot be private}} +{} #pragma omp target parallel private(da) // expected-error {{shared variable cannot be private}} +{} #pragma omp target parallel private(S2::S2s) // expected-error {{shared variable cannot be private}} +{} #pragma omp target parallel private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} +{} #pragma omp target parallel private(threadvar, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}} + {} #pragma omp target parallel shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}} foo(); #pragma omp target parallel firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}} foo(); #pragma omp target parallel private(i) + {} #pragma omp target parallel private(j) foo(); #pragma omp parallel firstprivate(i) @@ -160,18 +200,20 @@ int main(int argc, char **argv) { #pragma omp target parallel private(m) // OK foo(); #pragma omp target parallel private(h) // expected-error {{threadprivate or thread local variable cannot be private}} +{} #pragma omp target parallel private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}} #pragma omp parallel { int i; -#pragma omp target parallel private(i) - {} } #pragma omp target parallel shared(i) +{} #pragma omp target parallel private(i) +{} #pragma omp target parallel private(j) +{} #pragma omp target parallel private(i) - {} +{} static int si; #pragma omp target parallel private(si) // OK {} diff --git a/test/OpenMP/target_parallel_proc_bind_messages.cpp b/test/OpenMP/target_parallel_proc_bind_messages.cpp index 6d8f4c4234..56292ad437 100644 --- a/test/OpenMP/target_parallel_proc_bind_messages.cpp +++ b/test/OpenMP/target_parallel_proc_bind_messages.cpp @@ -4,10 +4,15 @@ void foo(); int main(int argc, char **argv) { #pragma omp target parallel proc_bind // expected-error {{expected '(' after 'proc_bind'}} + foo(); #pragma omp target parallel proc_bind ( // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel proc_bind () // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} + foo(); #pragma omp target parallel proc_bind (master // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel proc_bind (close), proc_bind(spread) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'proc_bind' clause}} + foo(); #pragma omp target parallel proc_bind (x) // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} foo(); @@ -15,6 +20,7 @@ int main(int argc, char **argv) { ++argc; #pragma omp target parallel proc_bind(close) + foo(); #pragma omp target parallel proc_bind(spread) ++argc; return 0; diff --git a/test/OpenMP/target_parallel_reduction_messages.cpp b/test/OpenMP/target_parallel_reduction_messages.cpp index 6f9441bf77..8a2366ea57 100644 --- a/test/OpenMP/target_parallel_reduction_messages.cpp +++ b/test/OpenMP/target_parallel_reduction_messages.cpp @@ -131,7 +131,7 @@ T tmain(T argc) { foo(); #pragma omp target parallel private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} foo(); -#pragma omp target parallel private(k) +#pragma omp parallel private(k) #pragma omp target parallel reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} foo(); #pragma omp target parallel reduction(+ : p), reduction(+ : p) // expected-error 3 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 3 {{previously referenced here}} @@ -139,17 +139,20 @@ T tmain(T argc) { #pragma omp target parallel reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}} foo(); #pragma omp target parallel shared(i) -#pragma omp target parallel reduction(min : i) + foo(); +#pragma omp parallel reduction(min : i) #pragma omp target parallel reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} foo(); #pragma omp target parallel #pragma omp for private(fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target parallel reduction(+ : fl) foo(); #pragma omp target parallel #pragma omp for reduction(- : fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target parallel reduction(+ : fl) foo(); @@ -228,7 +231,7 @@ int main(int argc, char **argv) { foo(); #pragma omp target parallel private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} foo(); -#pragma omp target parallel private(k) +#pragma omp parallel private(k) #pragma omp target parallel reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} foo(); #pragma omp target parallel reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}} @@ -236,17 +239,20 @@ int main(int argc, char **argv) { #pragma omp target parallel reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}} foo(); #pragma omp target parallel shared(i) -#pragma omp target parallel reduction(min : i) + foo(); +#pragma omp parallel reduction(min : i) #pragma omp target parallel reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} foo(); #pragma omp target parallel #pragma omp for private(fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target parallel reduction(+ : fl) foo(); #pragma omp target parallel #pragma omp for reduction(- : fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target parallel reduction(+ : fl) foo(); static int m; diff --git a/test/OpenMP/target_parallel_shared_messages.cpp b/test/OpenMP/target_parallel_shared_messages.cpp index 117b2e7af3..302a09239d 100644 --- a/test/OpenMP/target_parallel_shared_messages.cpp +++ b/test/OpenMP/target_parallel_shared_messages.cpp @@ -60,30 +60,49 @@ int main(int argc, char **argv) { int i; int &j = i; #pragma omp target parallel shared // expected-error {{expected '(' after 'shared'}} + foo(); #pragma omp target parallel shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel shared () // expected-error {{expected expression}} + foo(); #pragma omp target parallel shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} + foo(); #pragma omp target parallel shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} + foo(); #pragma omp target parallel shared (argc) + foo(); #pragma omp target parallel shared (S1) // expected-error {{'S1' does not refer to a value}} + foo(); #pragma omp target parallel shared (a, b, c, d, f) + foo(); #pragma omp target parallel shared (argv[1]) // expected-error {{expected variable name}} + foo(); #pragma omp target parallel shared(ba) + foo(); #pragma omp target parallel shared(ca) + foo(); #pragma omp target parallel shared(da) + foo(); #pragma omp target parallel shared(e, g) + foo(); #pragma omp target parallel shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}} + foo(); #pragma omp target parallel private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}} foo(); #pragma omp target parallel firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}} foo(); #pragma omp target parallel private(i) + foo(); #pragma omp target parallel shared(i) + foo(); #pragma omp target parallel shared(j) foo(); #pragma omp target parallel firstprivate(i) + foo(); #pragma omp target parallel shared(i) + foo(); #pragma omp target parallel shared(j) foo(); diff --git a/test/OpenMP/target_private_messages.cpp b/test/OpenMP/target_private_messages.cpp index 6c0ff04450..929e35d692 100644 --- a/test/OpenMP/target_private_messages.cpp +++ b/test/OpenMP/target_private_messages.cpp @@ -90,28 +90,39 @@ int foomain(I argc, C **argv) { int i; int &j = i; #pragma omp target private // expected-error {{expected '(' after 'private'}} +{} #pragma omp target private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private() // expected-error {{expected expression}} +{} #pragma omp target private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} +{} #pragma omp target private(argc) +{} #pragma omp target private(S1) // expected-error {{'S1' does not refer to a value}} +{} #pragma omp target private(a, b) // expected-error {{private variable with incomplete type 'S1'}} +{} #pragma omp target private(argv[1]) // expected-error {{expected variable name}} +{} #pragma omp target private(e, g) +{} #pragma omp target private(h) // expected-error {{threadprivate or thread local variable cannot be private}} +{} #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}} #pragma omp parallel { int v = 0; int i; -#pragma omp target private(i) - {} } #pragma omp parallel shared(i) #pragma omp parallel private(i) #pragma omp target private(j) +{} #pragma omp target private(i) {} return 0; @@ -139,28 +150,40 @@ int main(int argc, char **argv) { int i; int &j = i; #pragma omp target private // expected-error {{expected '(' after 'private'}} +{} #pragma omp target private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private() // expected-error {{expected expression}} +{} #pragma omp target private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} +{} #pragma omp target private(argc) +{} #pragma omp target private(S1) // expected-error {{'S1' does not refer to a value}} +{} #pragma omp target private(a, b) // expected-error {{private variable with incomplete type 'S1'}} +{} #pragma omp target private(argv[1]) // expected-error {{expected variable name}} +{} #pragma omp target private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} +{} #pragma omp target private(h) // expected-error {{threadprivate or thread local variable cannot be private}} +{} #pragma omp target private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}} +{} #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}} #pragma omp parallel { int i; -#pragma omp target private(i) - {} } #pragma omp parallel shared(i) #pragma omp parallel private(i) #pragma omp target private(j) +{} #pragma omp target private(i) {} static int si; diff --git a/test/OpenMP/teams_reduction_messages.cpp b/test/OpenMP/teams_reduction_messages.cpp index c9790e3b6a..d1be4b15ba 100644 --- a/test/OpenMP/teams_reduction_messages.cpp +++ b/test/OpenMP/teams_reduction_messages.cpp @@ -175,6 +175,7 @@ T tmain(T argc) { #pragma omp teams #pragma omp parallel for private(fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target #pragma omp teams reduction(+ : fl) foo(); @@ -182,6 +183,7 @@ T tmain(T argc) { #pragma omp teams #pragma omp parallel for reduction(- : fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target #pragma omp teams reduction(+ : fl) foo(); @@ -306,6 +308,7 @@ int main(int argc, char **argv) { #pragma omp teams #pragma omp parallel for private(fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target #pragma omp teams reduction(+ : fl) foo(); @@ -313,6 +316,7 @@ int main(int argc, char **argv) { #pragma omp teams #pragma omp parallel for reduction(- : fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target #pragma omp teams reduction(+ : fl) foo(); -- 2.40.0