1 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp \ 2 // RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions %s 3 4 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -verify -fopenmp \ 5 // RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions %s 6 7 int disp_variant(); 8 #pragma omp declare variant(disp_variant) \ 9 match(construct = {dispatch}, device = {arch(arm)}) 10 int disp_call(); 11 12 struct Obj { 13 int disp_method_variant1(); 14 #pragma omp declare variant(disp_method_variant1) \ 15 match(construct={dispatch}, device={arch(arm)}) 16 int disp_method1(); 17 int disp_method_variant2(); 18 #pragma omp declare variant(disp_method_variant2) \ 19 match(construct={dispatch}, device={arch(arm)}) 20 int disp_method2(); 21 }; 22 23 void testit_one(int dnum) { 24 // expected-error@+1 {{cannot contain more than one 'device' clause}} 25 #pragma omp dispatch device(dnum) device(3) 26 disp_call(); 27 28 // expected-error@+1 {{cannot contain more than one 'nowait' clause}} 29 #pragma omp dispatch nowait device(dnum) nowait 30 disp_call(); 31 32 // expected-error@+1 {{expected '(' after 'novariants'}} 33 #pragma omp dispatch novariants 34 disp_call(); 35 36 // expected-error@+3 {{expected expression}} 37 // expected-error@+2 {{expected ')'}} 38 // expected-note@+1 {{to match this '('}} 39 #pragma omp dispatch novariants ( 40 disp_call(); 41 42 // expected-error@+1 {{cannot contain more than one 'novariants' clause}} 43 #pragma omp dispatch novariants(dnum> 4) novariants(3) 44 disp_call(); 45 46 // expected-error@+1 {{use of undeclared identifier 'x'}} 47 #pragma omp dispatch novariants(x) 48 disp_call(); 49 50 // expected-error@+1 {{expected '(' after 'nocontext'}} 51 #pragma omp dispatch nocontext 52 disp_call(); 53 54 // expected-error@+3 {{expected expression}} 55 // expected-error@+2 {{expected ')'}} 56 // expected-note@+1 {{to match this '('}} 57 #pragma omp dispatch nocontext ( 58 disp_call(); 59 60 // expected-error@+1 {{cannot contain more than one 'nocontext' clause}} 61 #pragma omp dispatch nocontext(dnum> 4) nocontext(3) 62 disp_call(); 63 64 // expected-error@+1 {{use of undeclared identifier 'x'}} 65 #pragma omp dispatch nocontext(x) 66 disp_call(); 67 } 68 69 void testit_two() { 70 //expected-error@+2 {{cannot return from OpenMP region}} 71 #pragma omp dispatch 72 return disp_call(); 73 } 74 75 void testit_three(int (*fptr)(void), Obj *obj, int (Obj::*mptr)(void)) { 76 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 77 #pragma omp dispatch 78 fptr(); 79 80 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 81 #pragma omp dispatch 82 (obj->*mptr)(); 83 84 int ret; 85 86 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 87 #pragma omp dispatch 88 ret = fptr(); 89 90 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 91 #pragma omp dispatch 92 ret = (obj->*mptr)(); 93 } 94 95 void testit_four(int *x, int y, Obj *obj) 96 { 97 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 98 #pragma omp dispatch 99 *x = y; 100 101 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 102 #pragma omp dispatch 103 y = disp_call() + disp_call(); 104 105 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 106 #pragma omp dispatch 107 y = (y = disp_call()); 108 109 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 110 #pragma omp dispatch 111 y += disp_call(); 112 113 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 114 #pragma omp dispatch 115 for (int I = 0; I < 8; ++I) { 116 disp_call(); 117 } 118 } 119