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