148 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-mapping -Wuninitialized2 3// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-mapping -Wuninitialized4 5extern int omp_default_mem_alloc;6void foo() {7}8 9bool foobool(int argc) {10 return argc;11}12 13void xxx(int argc) {14 int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}15#pragma omp target16#pragma omp teams firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}17 for (int i = 0; i < 10; ++i)18 ;19}20 21struct S1; // expected-note {{declared here}} expected-note 2 {{forward declaration of 'S1'}}22extern S1 a;23class S2 {24 mutable int a;25 26public:27 S2() : a(0) {}28 S2(const S2 &s2) : a(s2.a) {}29 static float S2s;30 static const float S2sc;31};32const float S2::S2sc = 0;33const S2 b;34const S2 ba[5];35class S3 {36 int a;37 38public:39 S3() : a(0) {}40 S3(const S3 &s3) : a(s3.a) {}41};42const S3 c;43const S3 ca[5];44extern const int f;45class S4 {46 int a;47 S4();48 S4(const S4 &s4); // expected-note {{implicitly declared private here}}49public:50 S4(int v) : a(v) {}51};52class S5 {53 int a;54 S5() : a(0) {}55 S5(const S5 &s5) : a(s5.a) {} // expected-note {{implicitly declared private here}}56public:57 S5(int v) : a(v) {}58};59 60S3 h;61#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}62 63namespace A {64double x;65#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}66}67namespace B {68using A::x;69}70 71int main(int argc, char **argv) {72 const int d = 5;73 const int da[5] = {0};74 S4 e(4);75 S5 g(5);76 int i, z;77 int &j = i;78#pragma omp target79#pragma omp teams firstprivate // expected-error {{expected '(' after 'firstprivate'}}80 foo();81#pragma omp target82#pragma omp teams firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}83 foo();84#pragma omp target85#pragma omp teams firstprivate() // expected-error {{expected expression}}86 foo();87#pragma omp target88#pragma omp teams firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}89 foo();90#pragma omp target91#pragma omp teams firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}92 foo();93#pragma omp target94#pragma omp teams firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}95 foo();96#pragma omp target97#pragma omp teams 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 '('}}98 foo();99#pragma omp target100#pragma omp teams firstprivate(S1) // expected-error {{'S1' does not refer to a value}}101 foo();102#pragma omp target103#pragma omp teams firstprivate(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error {{firstprivate variable with incomplete type 'S1'}}104 foo();105#pragma omp target106#pragma omp teams firstprivate(argv[1]) // expected-error {{expected variable name}}107 foo();108#pragma omp target109#pragma omp teams firstprivate(ba, z)110 foo();111#pragma omp target112#pragma omp teams firstprivate(ca)113 foo();114#pragma omp target115#pragma omp teams firstprivate(da)116 foo();117#pragma omp target118#pragma omp teams firstprivate(S2::S2s)119 foo();120#pragma omp target121#pragma omp teams firstprivate(S2::S2sc)122 foo();123#pragma omp target124#pragma omp teams firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}125 foo();126#pragma omp target127#pragma omp teams firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}128 foo();129#pragma omp target130#pragma omp teams private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}131 foo();132#pragma omp target133#pragma omp teams shared(i)134 foo();135#pragma omp target136#pragma omp teams firstprivate(i)137 foo();138#pragma omp target139#pragma omp teams firstprivate(j)140 foo();141 static int m;142#pragma omp target143#pragma omp teams firstprivate(m) // OK144 foo();145 146 return 0;147}148