1*67e74705SXin Li // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -o - %s 2*67e74705SXin Li 3*67e74705SXin Li #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} 4*67e74705SXin Li 5*67e74705SXin Li int a, b; // expected-warning {{declaration is not declared in any declare target region}} 6*67e74705SXin Li __thread int t; // expected-note {{defined as threadprivate or thread local}} 7*67e74705SXin Li 8*67e74705SXin Li #pragma omp declare target . // expected-error {{expected '(' after 'declare target'}} 9*67e74705SXin Li 10*67e74705SXin Li #pragma omp declare target 11*67e74705SXin Li void f(); 12*67e74705SXin Li #pragma omp end declare target shared(a) // expected-warning {{extra tokens at the end of '#pragma omp end declare target' are ignored}} 13*67e74705SXin Li 14*67e74705SXin Li #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}} 15*67e74705SXin Li 16*67e74705SXin Li void c(); // expected-warning {{declaration is not declared in any declare target region}} 17*67e74705SXin Li 18*67e74705SXin Li extern int b; 19*67e74705SXin Li 20*67e74705SXin Li struct NonT { 21*67e74705SXin Li int a; 22*67e74705SXin Li }; 23*67e74705SXin Li 24*67e74705SXin Li typedef int sint; 25*67e74705SXin Li 26*67e74705SXin Li #pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}} 27*67e74705SXin Li #pragma omp threadprivate(a) // expected-note {{defined as threadprivate or thread local}} 28*67e74705SXin Li extern int b; 29*67e74705SXin Li int g; 30*67e74705SXin Li 31*67e74705SXin Li struct T { // expected-note {{mappable type cannot be polymorphic}} 32*67e74705SXin Li int a; 33*67e74705SXin Li virtual int method(); 34*67e74705SXin Li }; 35*67e74705SXin Li 36*67e74705SXin Li class VC { // expected-note {{mappable type cannot be polymorphic}} 37*67e74705SXin Li T member; 38*67e74705SXin Li NonT member1; 39*67e74705SXin Li public: method()40*67e74705SXin Li virtual int method() { T a; return 0; } // expected-error {{type 'T' is not mappable to target}} 41*67e74705SXin Li }; 42*67e74705SXin Li 43*67e74705SXin Li struct C { 44*67e74705SXin Li NonT a; 45*67e74705SXin Li sint b; 46*67e74705SXin Li int method(); 47*67e74705SXin Li int method1(); 48*67e74705SXin Li }; 49*67e74705SXin Li method1()50*67e74705SXin Liint C::method1() { 51*67e74705SXin Li return 0; 52*67e74705SXin Li } 53*67e74705SXin Li foo()54*67e74705SXin Livoid foo() { 55*67e74705SXin Li a = 0; // expected-error {{threadprivate variables cannot be used in target constructs}} 56*67e74705SXin Li b = 0; // expected-note {{used here}} 57*67e74705SXin Li t = 1; // expected-error {{threadprivate variables cannot be used in target constructs}} 58*67e74705SXin Li C object; 59*67e74705SXin Li VC object1; // expected-error {{type 'VC' is not mappable to target}} 60*67e74705SXin Li g = object.method(); 61*67e74705SXin Li g += object.method1(); 62*67e74705SXin Li g += object1.method(); 63*67e74705SXin Li f(); 64*67e74705SXin Li c(); // expected-note {{used here}} 65*67e74705SXin Li } 66*67e74705SXin Li #pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}} foo1()67*67e74705SXin Livoid foo1() {} 68*67e74705SXin Li #pragma omp end declare target 69*67e74705SXin Li #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} 70*67e74705SXin Li method()71*67e74705SXin Liint C::method() { 72*67e74705SXin Li return 0; 73*67e74705SXin Li } 74*67e74705SXin Li 75*67e74705SXin Li struct S { 76*67e74705SXin Li #pragma omp declare target // expected-error {{directive must be at file or namespace scope}} 77*67e74705SXin Li int v; 78*67e74705SXin Li #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} 79*67e74705SXin Li }; 80*67e74705SXin Li main(int argc,char ** argv)81*67e74705SXin Liint main (int argc, char **argv) { 82*67e74705SXin Li #pragma omp declare target // expected-error {{unexpected OpenMP directive '#pragma omp declare target'}} 83*67e74705SXin Li int v; 84*67e74705SXin Li #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} 85*67e74705SXin Li foo(); 86*67e74705SXin Li return (0); 87*67e74705SXin Li } 88*67e74705SXin Li 89*67e74705SXin Li namespace { 90*67e74705SXin Li #pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}} 91*67e74705SXin Li int x; 92*67e74705SXin Li } // expected-error {{expected '#pragma omp end declare target'}} 93*67e74705SXin Li #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} 94*67e74705SXin Li 95*67e74705SXin Li #pragma omp declare target link(S) // expected-error {{'S' used in declare target directive is not a variable or a function name}} 96*67e74705SXin Li 97*67e74705SXin Li #pragma omp declare target (x, x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}} 98*67e74705SXin Li #pragma omp declare target to(x) to(x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}} 99*67e74705SXin Li #pragma omp declare target link(x) // expected-error {{'x' must not appear in both clauses 'to' and 'link'}} 100*67e74705SXin Li 101*67e74705SXin Li #pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}} expected-note {{to match this '#pragma omp declare target'}} 102