| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s | ||
| // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s | ||
| // RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s | ||
| // expected-no-diagnostics | ||
|
|
||
| #ifndef HEADER | ||
| #define HEADER | ||
|
|
||
| void foo() {} | ||
|
|
||
| template <class T, int N> | ||
| T tmain(T argc) { | ||
| T b = argc, c, d, e, f, g; | ||
| static T a; | ||
| // CHECK: static T a; | ||
| #pragma omp parallel | ||
| #pragma omp sections private(argc, b), firstprivate(c, d), lastprivate(d, f) reduction (-: g) nowait | ||
| { | ||
| foo(); | ||
| } | ||
| // CHECK-NEXT: #pragma omp parallel | ||
| // CHECK-NEXT: #pragma omp sections private(argc,b) firstprivate(c,d) lastprivate(d,f) reduction(-: g) nowait | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: foo(); | ||
| // CHECK-NEXT: } | ||
| return T(); | ||
| } | ||
|
|
||
| int main(int argc, char **argv) { | ||
| int b = argc, c, d, e, f, g; | ||
| static int a; | ||
| // CHECK: static int a; | ||
| #pragma omp parallel | ||
| #pragma omp sections private(argc, b), firstprivate(argv, c), lastprivate(d, f) reduction(+:g) nowait | ||
| { | ||
| foo(); | ||
| } | ||
| // CHECK-NEXT: #pragma omp parallel | ||
| // CHECK-NEXT: #pragma omp sections private(argc,b) firstprivate(argv,c) lastprivate(d,f) reduction(+: g) nowait | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: foo(); | ||
| // CHECK-NEXT: } | ||
| return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0])); | ||
| } | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,335 @@ | ||
| // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s | ||
|
|
||
| void foo() { | ||
| } | ||
|
|
||
| bool foobool(int argc) { | ||
| return argc; | ||
| } | ||
|
|
||
| struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} | ||
| extern S1 a; | ||
| class S2 { | ||
| mutable int a; | ||
|
|
||
| public: | ||
| S2() : a(0) {} | ||
| S2(S2 &s2) : a(s2.a) {} | ||
| static float S2s; | ||
| static const float S2sc; | ||
| }; | ||
| const float S2::S2sc = 0; | ||
| const S2 b; | ||
| const S2 ba[5]; | ||
| class S3 { | ||
| int a; | ||
| S3 &operator=(const S3 &s3); | ||
|
|
||
| public: | ||
| S3() : a(0) {} | ||
| S3(S3 &s3) : a(s3.a) {} | ||
| }; | ||
| const S3 c; | ||
| const S3 ca[5]; | ||
| extern const int f; | ||
| class S4 { // expected-note 2 {{'S4' declared here}} | ||
| int a; | ||
| S4(); | ||
| S4(const S4 &s4); | ||
|
|
||
| public: | ||
| S4(int v) : a(v) {} | ||
| }; | ||
| class S5 { // expected-note 4 {{'S5' declared here}} | ||
| int a; | ||
| S5(const S5 &s5) : a(s5.a) {} | ||
|
|
||
| public: | ||
| S5() : a(0) {} | ||
| S5(int v) : a(v) {} | ||
| }; | ||
| class S6 { | ||
| int a; | ||
| S6() : a(0) {} | ||
|
|
||
| public: | ||
| S6(const S6 &s6) : a(s6.a) {} | ||
| S6(int v) : a(v) {} | ||
| }; | ||
|
|
||
| S3 h; | ||
| #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} | ||
|
|
||
| template <class I, class C> | ||
| int foomain(int argc, char **argv) { | ||
| I e(4); // expected-note {{'e' defined here}} | ||
| C g(5); // expected-note 2 {{'g' defined here}} | ||
| int i; | ||
| int &j = i; // expected-note {{'j' defined here}} | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate // expected-error {{expected '(' after 'firstprivate'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate() // expected-error {{expected expression}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(argc) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(argv[1]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| { | ||
| int v = 0; | ||
| int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp sections' directive into a parallel or another task region?}} | ||
| #pragma omp sections firstprivate(i) // expected-error {{private variable cannot be firstprivate}} | ||
| { | ||
| foo(); | ||
| } | ||
| v += i; | ||
| } | ||
| #pragma omp parallel shared(i) | ||
| #pragma omp parallel private(i) | ||
| #pragma omp sections firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(i) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel private(i) // expected-note {{defined as private}} | ||
| #pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}} | ||
| #pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}} | ||
| { | ||
| foo(); | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| int main(int argc, char **argv) { | ||
| const int d = 5; | ||
| const int da[5] = {0}; | ||
| S4 e(4); // expected-note {{'e' defined here}} | ||
| S5 g(5); // expected-note 2 {{'g' defined here}} | ||
| S3 m; | ||
| S6 n(2); | ||
| int i; | ||
| int &j = i; // expected-note {{'j' defined here}} | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate // expected-error {{expected '(' after 'firstprivate'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate() // expected-error {{expected expression}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(argc) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(argv[1]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(2 * 2) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(ba) // OK | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(ca) // OK | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(da) // OK | ||
| { | ||
| foo(); | ||
| } | ||
| int xa; | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(xa) // OK | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(S2::S2s) // OK | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(S2::S2sc) // OK | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp sections'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(m) // OK | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel shared(xa) | ||
| #pragma omp sections firstprivate(xa) // OK: may be firstprivate | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(n) firstprivate(n) // OK | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| { | ||
| int v = 0; | ||
| int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp sections' directive into a parallel or another task region?}} | ||
| #pragma omp sections firstprivate(i) // expected-error {{private variable cannot be firstprivate}} | ||
| { | ||
| foo(); | ||
| } | ||
| v += i; | ||
| } | ||
| #pragma omp parallel private(i) // expected-note {{defined as private}} | ||
| #pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}} | ||
| #pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}} | ||
| { | ||
| foo(); | ||
| } | ||
|
|
||
| return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,309 @@ | ||
| // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s | ||
|
|
||
| void foo() { | ||
| } | ||
|
|
||
| bool foobool(int argc) { | ||
| return argc; | ||
| } | ||
|
|
||
| struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} | ||
| extern S1 a; | ||
| class S2 { | ||
| mutable int a; | ||
|
|
||
| public: | ||
| S2() : a(0) {} | ||
| S2(S2 &s2) : a(s2.a) {} | ||
| static float S2s; // expected-note {{static data member is predetermined as shared}} | ||
| static const float S2sc; | ||
| }; | ||
| const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}} | ||
| const S2 b; | ||
| const S2 ba[5]; | ||
| class S3 { // expected-note 2 {{'S3' declared here}} | ||
| int a; | ||
| S3 &operator=(const S3 &s3); | ||
|
|
||
| public: | ||
| S3() : a(0) {} | ||
| S3(S3 &s3) : a(s3.a) {} | ||
| }; | ||
| const S3 c; // expected-note {{global variable is predetermined as shared}} | ||
| const S3 ca[5]; // expected-note {{global variable is predetermined as shared}} | ||
| extern const int f; // expected-note {{global variable is predetermined as shared}} | ||
| class S4 { // expected-note 3 {{'S4' declared here}} | ||
| int a; | ||
| S4(); | ||
| S4(const S4 &s4); | ||
|
|
||
| public: | ||
| S4(int v) : a(v) {} | ||
| }; | ||
| class S5 { // expected-note {{'S5' declared here}} | ||
| int a; | ||
| S5() : a(0) {} | ||
|
|
||
| public: | ||
| S5(const S5 &s5) : a(s5.a) {} | ||
| S5(int v) : a(v) {} | ||
| }; | ||
| class S6 { | ||
| int a; | ||
| S6() : a(0) {} | ||
|
|
||
| public: | ||
| S6(const S6 &s6) : a(s6.a) {} | ||
| S6(int v) : a(v) {} | ||
| }; | ||
|
|
||
| S3 h; | ||
| #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} | ||
|
|
||
| template <class I, class C> | ||
| int foomain(int argc, char **argv) { | ||
| I e(4); // expected-note {{'e' defined here}} | ||
| I g(5); // expected-note {{'g' defined here}} | ||
| int i; | ||
| int &j = i; // expected-note {{'j' defined here}} | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate // expected-error {{expected '(' after 'lastprivate'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate() // expected-error {{expected expression}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(argc) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(argv[1]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| { | ||
| int v = 0; | ||
| int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp sections' directive into a parallel or another task region?}} | ||
| #pragma omp sections lastprivate(i) // expected-error {{lastprivate variable must be shared}} | ||
| { | ||
| foo(); | ||
| } | ||
| v += i; | ||
| } | ||
| #pragma omp parallel shared(i) | ||
| #pragma omp parallel private(i) | ||
| #pragma omp sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(i) | ||
| { | ||
| foo(); | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| int main(int argc, char **argv) { | ||
| const int d = 5; // expected-note {{constant variable is predetermined as shared}} | ||
| const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}} | ||
| S4 e(4); // expected-note {{'e' defined here}} | ||
| S5 g(5); // expected-note {{'g' defined here}} | ||
| S3 m; // expected-note 2 {{'m' defined here}} | ||
| S6 n(2); | ||
| int i; | ||
| int &j = i; // expected-note {{'j' defined here}} | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate // expected-error {{expected '(' after 'lastprivate'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate() // expected-error {{expected expression}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(argc) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(argv[1]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(2 * 2) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(ba) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(da) // expected-error {{shared variable cannot be lastprivate}} | ||
| { | ||
| foo(); | ||
| } | ||
| int xa; | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(xa) // OK | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp sections'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(i) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel private(xa) // expected-note {{defined as private}} | ||
| #pragma omp sections lastprivate(xa) // expected-error {{lastprivate variable must be shared}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel reduction(+ : xa) // expected-note {{defined as reduction}} | ||
| #pragma omp sections lastprivate(xa) // expected-error {{lastprivate variable must be shared}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections firstprivate(m) lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(n) firstprivate(n) // OK | ||
| { | ||
| foo(); | ||
| } | ||
| return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,271 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -verify %s | ||
|
|
||
| void foo(); | ||
|
|
||
| // expected-error@+1 {{unexpected OpenMP directive '#pragma omp sections'}} | ||
| #pragma omp sections | ||
|
|
||
| // expected-error@+1 {{unexpected OpenMP directive '#pragma omp sections'}} | ||
| #pragma omp sections foo | ||
|
|
||
| void test_no_clause() { | ||
| int i; | ||
| #pragma omp sections | ||
| { | ||
| foo(); | ||
| } | ||
|
|
||
| // expected-error@+2 {{the statement for '#pragma omp sections' must be a compound statement}} | ||
| #pragma omp sections | ||
| ++i; | ||
| } | ||
|
|
||
| void test_branch_protected_scope() { | ||
| int i = 0; | ||
| L1: | ||
| ++i; | ||
|
|
||
| int x[24]; | ||
|
|
||
| #pragma omp parallel | ||
| #pragma omp sections | ||
| { | ||
| if (i == 5) | ||
| goto L1; // expected-error {{use of undeclared label 'L1'}} | ||
| else if (i == 6) | ||
| return; // expected-error {{cannot return from OpenMP region}} | ||
| else if (i == 7) | ||
| goto L2; | ||
| else if (i == 8) { | ||
| L2: | ||
| x[i]++; | ||
| } | ||
| } | ||
|
|
||
| if (x[0] == 0) | ||
| goto L2; // expected-error {{use of undeclared label 'L2'}} | ||
| else if (x[1] == 1) | ||
| goto L1; | ||
| } | ||
|
|
||
| void test_invalid_clause() { | ||
| int i; | ||
| #pragma omp parallel | ||
| // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}} | ||
| #pragma omp sections foo bar | ||
| { | ||
| foo(); | ||
| } | ||
| } | ||
|
|
||
| void test_non_identifiers() { | ||
| int i, x; | ||
|
|
||
| #pragma omp parallel | ||
| // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}} | ||
| #pragma omp sections; | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}} | ||
| // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}} | ||
| #pragma omp sections linear(x); | ||
| { | ||
| foo(); | ||
| } | ||
|
|
||
| #pragma omp parallel | ||
| // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}} | ||
| #pragma omp sections private(x); | ||
| { | ||
| foo(); | ||
| } | ||
|
|
||
| #pragma omp parallel | ||
| // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}} | ||
| #pragma omp sections, private(x); | ||
| { | ||
| foo(); | ||
| } | ||
| } | ||
|
|
||
| void test_private() { | ||
| int i; | ||
| #pragma omp parallel | ||
| // expected-error@+2 {{expected expression}} | ||
| // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} | ||
| #pragma omp sections private( | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} | ||
| // expected-error@+1 2 {{expected expression}} | ||
| #pragma omp sections private(, | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 2 {{expected expression}} | ||
| #pragma omp sections private(, ) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 {{expected expression}} | ||
| #pragma omp sections private() | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 {{expected expression}} | ||
| #pragma omp sections private(int) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 {{expected variable name}} | ||
| #pragma omp sections private(0) | ||
| { | ||
| foo(); | ||
| } | ||
|
|
||
| int x, y, z; | ||
| #pragma omp parallel | ||
| #pragma omp sections private(x) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections private(x, y) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections private(x, y, z) | ||
| { | ||
| foo(); | ||
| } | ||
| } | ||
|
|
||
| void test_lastprivate() { | ||
| int i; | ||
| #pragma omp parallel | ||
| // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} | ||
| // expected-error@+1 {{expected expression}} | ||
| #pragma omp sections lastprivate( | ||
| { | ||
| foo(); | ||
| } | ||
|
|
||
| #pragma omp parallel | ||
| // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} | ||
| // expected-error@+1 2 {{expected expression}} | ||
| #pragma omp sections lastprivate(, | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 2 {{expected expression}} | ||
| #pragma omp sections lastprivate(, ) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 {{expected expression}} | ||
| #pragma omp sections lastprivate() | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 {{expected expression}} | ||
| #pragma omp sections lastprivate(int) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 {{expected variable name}} | ||
| #pragma omp sections lastprivate(0) | ||
| { | ||
| foo(); | ||
| } | ||
|
|
||
| int x, y, z; | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(x) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(x, y) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(x, y, z) | ||
| { | ||
| foo(); | ||
| } | ||
| } | ||
|
|
||
| void test_firstprivate() { | ||
| int i; | ||
| #pragma omp parallel | ||
| // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} | ||
| // expected-error@+1 {{expected expression}} | ||
| #pragma omp sections firstprivate( | ||
| { | ||
| foo(); | ||
| } | ||
|
|
||
| #pragma omp parallel | ||
| // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} | ||
| // expected-error@+1 2 {{expected expression}} | ||
| #pragma omp sections firstprivate(, | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 2 {{expected expression}} | ||
| #pragma omp sections firstprivate(, ) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 {{expected expression}} | ||
| #pragma omp sections firstprivate() | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 {{expected expression}} | ||
| #pragma omp sections firstprivate(int) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| // expected-error@+1 {{expected variable name}} | ||
| #pragma omp sections firstprivate(0) | ||
| { | ||
| foo(); | ||
| } | ||
|
|
||
| int x, y, z; | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(x) firstprivate(x) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(x, y) firstprivate(x, y) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| #pragma omp sections lastprivate(x, y, z) firstprivate(x, y, z) | ||
| { | ||
| foo(); | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,204 @@ | ||
| // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s | ||
|
|
||
| void foo() { | ||
| } | ||
|
|
||
| bool foobool(int argc) { | ||
| return argc; | ||
| } | ||
|
|
||
| struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} | ||
| extern S1 a; | ||
| class S2 { | ||
| mutable int a; | ||
|
|
||
| public: | ||
| S2() : a(0) {} | ||
| }; | ||
| const S2 b; | ||
| const S2 ba[5]; | ||
| class S3 { | ||
| int a; | ||
|
|
||
| public: | ||
| S3() : a(0) {} | ||
| }; | ||
| const S3 ca[5]; | ||
| class S4 { // expected-note {{'S4' declared here}} | ||
| int a; | ||
| S4(); | ||
|
|
||
| public: | ||
| S4(int v) : a(v) {} | ||
| }; | ||
| class S5 { // expected-note {{'S5' declared here}} | ||
| int a; | ||
| S5() : a(0) {} | ||
|
|
||
| public: | ||
| S5(int v) : a(v) {} | ||
| }; | ||
|
|
||
| S3 h; | ||
| #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} | ||
|
|
||
| template <class I, class C> | ||
| int foomain(I argc, C **argv) { | ||
| I e(4); | ||
| I g(5); | ||
| int i; | ||
| int &j = i; // expected-note {{'j' defined here}} | ||
| #pragma omp sections private // expected-error {{expected '(' after 'private'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private() // expected-error {{expected expression}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(argc) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(S1) // expected-error {{'S1' does not refer to a value}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(a, b) // expected-error {{private variable with incomplete type 'S1'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(argv[1]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(e, g) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(h) // expected-error {{threadprivate or thread local variable cannot be private}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp sections'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| { | ||
| int v = 0; | ||
| int i; | ||
| #pragma omp sections private(i) | ||
| { | ||
| foo(); | ||
| } | ||
| v += i; | ||
| } | ||
| #pragma omp parallel shared(i) | ||
| #pragma omp parallel private(i) | ||
| #pragma omp sections private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(i) | ||
| { | ||
| foo(); | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| int main(int argc, char **argv) { | ||
| S4 e(4); // expected-note {{'e' defined here}} | ||
| S5 g(5); // expected-note {{'g' defined here}} | ||
| int i; | ||
| int &j = i; // expected-note {{'j' defined here}} | ||
| #pragma omp sections private // expected-error {{expected '(' after 'private'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private() // expected-error {{expected expression}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(argc) | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(S1) // expected-error {{'S1' does not refer to a value}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(a, b) // expected-error {{private variable with incomplete type 'S1'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(argv[1]) // expected-error {{expected variable name}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(h) // expected-error {{threadprivate or thread local variable cannot be private}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp sections'}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp parallel | ||
| { | ||
| int i; | ||
| #pragma omp sections private(i) | ||
| { | ||
| foo(); | ||
| } | ||
| } | ||
| #pragma omp parallel shared(i) | ||
| #pragma omp parallel private(i) | ||
| #pragma omp sections private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}} | ||
| { | ||
| foo(); | ||
| } | ||
| #pragma omp sections private(i) | ||
| { | ||
| foo(); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|