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 33 void testit_two() { 34 //expected-error@+2 {{cannot return from OpenMP region}} 35 #pragma omp dispatch 36 return disp_call(); 37 } 38 39 void testit_three(int (*fptr)(void), Obj *obj, int (Obj::*mptr)(void)) { 40 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 41 #pragma omp dispatch 42 fptr(); 43 44 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 45 #pragma omp dispatch 46 (obj->*mptr)(); 47 48 int ret; 49 50 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 51 #pragma omp dispatch 52 ret = fptr(); 53 54 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 55 #pragma omp dispatch 56 ret = (obj->*mptr)(); 57 } 58 59 void testit_four(int *x, int y, Obj *obj) 60 { 61 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 62 #pragma omp dispatch 63 *x = y; 64 65 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 66 #pragma omp dispatch 67 y = disp_call() + disp_call(); 68 69 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 70 #pragma omp dispatch 71 y = (y = disp_call()); 72 73 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 74 #pragma omp dispatch 75 y += disp_call(); 76 77 //expected-error@+2 {{statement after '#pragma omp dispatch' must be a direct call to a target function or an assignment to one}} 78 #pragma omp dispatch 79 for (int I = 0; I < 8; ++I) { 80 disp_call(); 81 } 82 } 83