Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / dispatch_messages.cpp
blob27592e18adfa70519610599f2e3bac6a928adedf
1 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp \
2 // RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions %s
4 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -verify -fopenmp \
5 // RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions %s
7 int disp_variant();
8 #pragma omp declare variant(disp_variant) \
9 match(construct = {dispatch}, device = {arch(arm)})
10 int disp_call();
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();
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();
28 // expected-error@+1 {{cannot contain more than one 'nowait' clause}}
29 #pragma omp dispatch nowait device(dnum) nowait
30 disp_call();
32 // expected-error@+1 {{expected '(' after 'novariants'}}
33 #pragma omp dispatch novariants
34 disp_call();
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();
42 // expected-error@+1 {{cannot contain more than one 'novariants' clause}}
43 #pragma omp dispatch novariants(dnum> 4) novariants(3)
44 disp_call();
46 // expected-error@+1 {{use of undeclared identifier 'x'}}
47 #pragma omp dispatch novariants(x)
48 disp_call();
50 // expected-error@+1 {{expected '(' after 'nocontext'}}
51 #pragma omp dispatch nocontext
52 disp_call();
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();
60 // expected-error@+1 {{cannot contain more than one 'nocontext' clause}}
61 #pragma omp dispatch nocontext(dnum> 4) nocontext(3)
62 disp_call();
64 // expected-error@+1 {{use of undeclared identifier 'x'}}
65 #pragma omp dispatch nocontext(x)
66 disp_call();
69 void testit_two() {
70 //expected-error@+2 {{cannot return from OpenMP region}}
71 #pragma omp dispatch
72 return disp_call();
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();
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)();
84 int ret;
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();
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)();
95 void testit_four(int *x, int y, Obj *obj)
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;
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();
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());
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();
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();