arpith-jacob created this revision. arpith-jacob added reviewers: hfinkel, kkwli0, sfantao, carlo.bertolli, ABataev. arpith-jacob added subscribers: cfe-commits, fraggamuffin, caomhin.
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. http://reviews.llvm.org/D16758 Files: include/clang/Basic/OpenMPKinds.h lib/Basic/OpenMPKinds.cpp lib/Sema/SemaOpenMP.cpp test/OpenMP/distribute_private_messages.cpp test/OpenMP/nesting_of_regions.cpp test/OpenMP/target_data_device_messages.cpp test/OpenMP/target_device_messages.cpp test/OpenMP/target_if_messages.cpp test/OpenMP/target_messages.cpp test/OpenMP/target_parallel_default_messages.cpp test/OpenMP/target_parallel_device_messages.cpp test/OpenMP/target_parallel_firstprivate_messages.cpp test/OpenMP/target_parallel_if_messages.cpp test/OpenMP/target_parallel_map_messages.cpp test/OpenMP/target_parallel_messages.cpp test/OpenMP/target_parallel_num_threads_messages.cpp test/OpenMP/target_parallel_private_messages.cpp test/OpenMP/target_parallel_proc_bind_messages.cpp test/OpenMP/target_parallel_reduction_messages.cpp test/OpenMP/target_parallel_shared_messages.cpp test/OpenMP/target_private_messages.cpp test/OpenMP/teams_reduction_messages.cpp
Index: test/OpenMP/teams_reduction_messages.cpp =================================================================== --- test/OpenMP/teams_reduction_messages.cpp +++ test/OpenMP/teams_reduction_messages.cpp @@ -175,13 +175,15 @@ #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(); #pragma omp target #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,13 +308,15 @@ #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(); #pragma omp target #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(); Index: test/OpenMP/target_private_messages.cpp =================================================================== --- test/OpenMP/target_private_messages.cpp +++ test/OpenMP/target_private_messages.cpp @@ -90,28 +90,39 @@ 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 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; Index: test/OpenMP/target_parallel_shared_messages.cpp =================================================================== --- test/OpenMP/target_parallel_shared_messages.cpp +++ test/OpenMP/target_parallel_shared_messages.cpp @@ -60,30 +60,49 @@ 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(); Index: test/OpenMP/target_parallel_reduction_messages.cpp =================================================================== --- test/OpenMP/target_parallel_reduction_messages.cpp +++ test/OpenMP/target_parallel_reduction_messages.cpp @@ -131,25 +131,28 @@ 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}} foo(); #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,25 +231,28 @@ 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}} foo(); #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; Index: test/OpenMP/target_parallel_proc_bind_messages.cpp =================================================================== --- test/OpenMP/target_parallel_proc_bind_messages.cpp +++ test/OpenMP/target_parallel_proc_bind_messages.cpp @@ -4,17 +4,23 @@ 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(); #pragma omp target parallel proc_bind(master) ++argc; #pragma omp target parallel proc_bind(close) + foo(); #pragma omp target parallel proc_bind(spread) ++argc; return 0; Index: test/OpenMP/target_parallel_private_messages.cpp =================================================================== --- test/OpenMP/target_parallel_private_messages.cpp +++ test/OpenMP/target_parallel_private_messages.cpp @@ -61,28 +61,47 @@ 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 @@ #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 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 @@ #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 {} Index: test/OpenMP/target_parallel_num_threads_messages.cpp =================================================================== --- test/OpenMP/target_parallel_num_threads_messages.cpp +++ test/OpenMP/target_parallel_num_threads_messages.cpp @@ -14,33 +14,54 @@ template <class T, typename S, int N> // 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(); return argc; } 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<int, char, -1>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} expected-note {{in instantiation of function template specialization 'tmain<int, char, -1>' requested here}} + foo(); #pragma omp target parallel redef_num_threads (argc, argc) foo(); Index: test/OpenMP/target_parallel_messages.cpp =================================================================== --- test/OpenMP/target_parallel_messages.cpp +++ test/OpenMP/target_parallel_messages.cpp @@ -24,6 +24,7 @@ #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(); Index: test/OpenMP/target_parallel_map_messages.cpp =================================================================== --- test/OpenMP/target_parallel_map_messages.cpp +++ test/OpenMP/target_parallel_map_messages.cpp @@ -65,13 +65,21 @@ #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 @@ #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 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 @@ #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(); Index: test/OpenMP/target_parallel_if_messages.cpp =================================================================== --- test/OpenMP/target_parallel_if_messages.cpp +++ test/OpenMP/target_parallel_if_messages.cpp @@ -12,51 +12,90 @@ template <class T, class S> // 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(); return 0; } 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(); Index: test/OpenMP/target_parallel_firstprivate_messages.cpp =================================================================== --- test/OpenMP/target_parallel_firstprivate_messages.cpp +++ test/OpenMP/target_parallel_firstprivate_messages.cpp @@ -64,27 +64,47 @@ 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(); Index: test/OpenMP/target_parallel_device_messages.cpp =================================================================== --- test/OpenMP/target_parallel_device_messages.cpp +++ test/OpenMP/target_parallel_device_messages.cpp @@ -11,16 +11,27 @@ 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(); Index: test/OpenMP/target_parallel_default_messages.cpp =================================================================== --- test/OpenMP/target_parallel_default_messages.cpp +++ test/OpenMP/target_parallel_default_messages.cpp @@ -4,17 +4,23 @@ 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(); #pragma omp target parallel default(none) ++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; Index: test/OpenMP/target_messages.cpp =================================================================== --- test/OpenMP/target_messages.cpp +++ test/OpenMP/target_messages.cpp @@ -21,6 +21,7 @@ #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(); Index: test/OpenMP/target_if_messages.cpp =================================================================== --- test/OpenMP/target_if_messages.cpp +++ test/OpenMP/target_if_messages.cpp @@ -12,45 +12,78 @@ template <class T, class S> // 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(); return 0; } 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(); Index: test/OpenMP/target_device_messages.cpp =================================================================== --- test/OpenMP/target_device_messages.cpp +++ test/OpenMP/target_device_messages.cpp @@ -11,16 +11,27 @@ 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(); Index: test/OpenMP/target_data_device_messages.cpp =================================================================== --- test/OpenMP/target_data_device_messages.cpp +++ test/OpenMP/target_data_device_messages.cpp @@ -21,8 +21,8 @@ #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; Index: test/OpenMP/nesting_of_regions.cpp =================================================================== --- test/OpenMP/nesting_of_regions.cpp +++ test/OpenMP/nesting_of_regions.cpp @@ -2666,12 +2666,12 @@ } #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 @@ } #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 @@ } #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 @@ } #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 @@ #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 @@ #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 @@ } #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 @@ } #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 @@ } #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 @@ #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 @@ #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 @@ #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; } } Index: test/OpenMP/distribute_private_messages.cpp =================================================================== --- test/OpenMP/distribute_private_messages.cpp +++ test/OpenMP/distribute_private_messages.cpp @@ -98,6 +98,7 @@ #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 @@ #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; } Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -809,7 +809,7 @@ 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 @@ DSAStack->hasDirective( [](OpenMPDirectiveKind K, const DeclarationNameInfo &DNI, SourceLocation Loc) -> bool { - return isOpenMPTargetDirective(K); + return isOpenMPTargetExecutionDirective(K); }, false)) { return true; @@ -944,7 +944,8 @@ auto *VD = dyn_cast<VarDecl>(D); return VD && !VD->hasLocalStorage() && - DSAStack->hasExplicitDirective(isOpenMPTargetDirective, Level); + DSAStack->hasExplicitDirective(isOpenMPTargetExecutionDirective, + Level); } void Sema::DestroyDataSharingAttributesStack() { delete DSAStack; } @@ -2313,11 +2314,11 @@ // | 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 @@ // | 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 @@ // +------------------+-----------------+------------------------------------+ if (Stack->getCurScope()) { auto ParentRegion = Stack->getParentDirective(); + auto OffendingRegion = ParentRegion; bool NestingProhibited = false; bool CloseNesting = true; enum { @@ -2658,10 +2660,32 @@ 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; } } Index: lib/Basic/OpenMPKinds.cpp =================================================================== --- lib/Basic/OpenMPKinds.cpp +++ lib/Basic/OpenMPKinds.cpp @@ -576,8 +576,15 @@ // 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) { Index: include/clang/Basic/OpenMPKinds.h =================================================================== --- include/clang/Basic/OpenMPKinds.h +++ include/clang/Basic/OpenMPKinds.h @@ -156,11 +156,20 @@ /// 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.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits