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 51 void testit_two() { 52 //expected-error@+2 {{cannot return from OpenMP region}} 53 #pragma omp dispatch 54 return disp_call(); 55 } 56 57 void testit_three(int (*fptr)(void), Obj *obj, int (Obj::*mptr)(void)) { 58 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 59 #pragma omp dispatch 60 fptr(); 61 62 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 63 #pragma omp dispatch 64 (obj->*mptr)(); 65 66 int ret; 67 68 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 69 #pragma omp dispatch 70 ret = fptr(); 71 72 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 73 #pragma omp dispatch 74 ret = (obj->*mptr)(); 75 } 76 77 void testit_four(int *x, int y, Obj *obj) 78 { 79 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 80 #pragma omp dispatch 81 *x = y; 82 83 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 84 #pragma omp dispatch 85 y = disp_call() + disp_call(); 86 87 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 88 #pragma omp dispatch 89 y = (y = disp_call()); 90 91 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 92 #pragma omp dispatch 93 y += disp_call(); 94 95 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 96 #pragma omp dispatch 97 for (int I = 0; I < 8; ++I) { 98 disp_call(); 99 } 100 } 101