Clang Project

clang_source_code/test/OpenMP/parallel_firstprivate_messages.cpp
1// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
2
3// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s
4
5extern int omp_default_mem_alloc;
6void foo() {
7}
8
9bool foobool(int argc) {
10  return argc;
11}
12
13struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
14extern S1 a;
15class S2 {
16  mutable int a;
17public:
18  S2():a(0) { }
19  S2(const S2 &s2):a(s2.a) { }
20  static float S2s;
21  static const float S2sc;
22};
23const float S2::S2sc = 0;
24const S2 b;
25const S2 ba[5];
26class S3 {
27  int a;
28public:
29  S3():a(0) { }
30  S3(const S3 &s3):a(s3.a) { }
31};
32const S3 c;
33const S3 ca[5];
34extern const int f;
35class S4 {
36  int a;
37  S4();
38  S4(const S4 &s4); // expected-note {{implicitly declared private here}}
39public:
40  S4(int v):a(v) { }
41};
42class S5 {
43  int a;
44  S5():a(0) {}
45  S5(const S5 &s5):a(s5.a) { } // expected-note {{implicitly declared private here}}
46public:
47  S5(int v):a(v) { }
48};
49
50S3 h;
51#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
52
53namespace A {
54double x;
55#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
56}
57namespace B {
58using A::x;
59}
60
61int main(int argc, char **argv) {
62  const int d = 5; // expected-note {{variable 'd' declared const here}}
63  const int da[5] = { 0 };
64  S4 e(4);
65  S5 g(5);
66  int i;
67  int &j = i;
68  static int m;
69  #pragma omp parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}}
70  #pragma omp parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
71  #pragma omp parallel firstprivate () // expected-error {{expected expression}}
72  #pragma omp parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
73  #pragma omp parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
74  #pragma omp parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
75  #pragma omp parallel firstprivate (argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}
76  #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
77  #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
78  #pragma omp parallel firstprivate (d)
79    d = 5; // expected-error {{cannot assign to variable 'd' with const-qualified type}}
80  #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
81  #pragma omp parallel firstprivate(ba)
82  #pragma omp parallel firstprivate(ca)
83  #pragma omp parallel firstprivate(da)
84  #pragma omp parallel firstprivate(S2::S2s)
85  #pragma omp parallel firstprivate(S2::S2sc)
86  #pragma omp parallel firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
87  #pragma omp parallel firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
88  #pragma omp parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
89  foo();
90  #pragma omp parallel shared(i)
91  #pragma omp parallel firstprivate(i)
92  #pragma omp parallel firstprivate(j)
93  #pragma omp parallel firstprivate(m)
94  foo();
95
96  return 0;
97}
98