Debian Codegraph @

gcc/testsuite/gcc.dg/gomp/append-args-1.c

raw
1 /* { dg-do compile } */
2 /* { dg-additional-options "-std=gnu17" } */
3
4 /* The errors might be a bit questionable, but still a resonable solution
5 for questionable code ... */
6
7 /* For all empty args, assume C < C23; in C++/C23 it becomes the same as '…(void)'. */
8
9 /* This uses append_args, once with adjust_args and once without. */
10
11 typedef enum omp_interop_t
12 {
13 omp_interop_none = 0,
14 __omp_interop_t_max__ = __UINTPTR_MAX__
15 } omp_interop_t;
16
17
18 /* (A) No prototype for the variant but for the base function. */
19
20 void variant_fn1();
21 #pragma omp declare variant(variant_fn1) match(construct={dispatch}) append_args(interop(target)) \
22 adjust_args(need_device_ptr: x,y)
23 void bar1(int *x, int *y);
24 /* { dg-error "variant 'variant_fn1' and base 'bar1' have incompatible types" "" { target *-*-* } .-3 } */
25
26
27 void variant_fn2();
28 #pragma omp declare variant(variant_fn2) match(construct={dispatch}) append_args(interop(target))
29 void bar2(int *x, int *y);
30 /* { dg-error "variant 'variant_fn2' and base 'bar2' have incompatible types" "" { target *-*-* } .-2 } */
31
32
33
34 /* (B) No prototype for the variant nor for the base function. */
35
36 void variant_fn3(); /* { dg-error "argument 1 of 'variant_fn3' must be of 'omp_interop_t'" } */
37 #pragma omp declare variant(variant_fn3) match(construct={dispatch}) append_args(interop(target)) \
38 adjust_args(need_device_ptr: x,y)
39 void bar3();
40 /* { dg-error "'x' undeclared here \\(not in a function\\)" "" { target *-*-* } .-2 } */
41 /* { dg-error "'y' undeclared here \\(not in a function\\)" "" { target *-*-* } .-3 } */
42 /* { dg-note "'append_args' specified here" "" { target *-*-* } .-5 } */
43
44
45 void variant_fn4(); /* { dg-error "argument 1 of 'variant_fn4' must be of 'omp_interop_t'" } */
46 #pragma omp declare variant(variant_fn4) match(construct={dispatch}) append_args(interop(target))
47 void bar4();
48 /* { dg-note "'append_args' specified here" "" { target *-*-* } .-2 } */
49
50
51
52 /* (C) Only a prototype on the variant-function side. */
53
54 void variant_fn5(omp_interop_t, omp_interop_t);
55 #pragma omp declare variant(variant_fn5) match(construct={dispatch}) append_args(interop(target)) \
56 adjust_args(need_device_ptr: x,y)
57 void bar5();
58 /* { dg-error "variant 'variant_fn5' and base 'bar5' have incompatible types" "" { target *-*-* } .-3 } */
59
60
61 void variant_fn6(omp_interop_t, omp_interop_t);
62 #pragma omp declare variant(variant_fn6) match(construct={dispatch}) append_args(interop(target))
63 void bar6();
64 /* { dg-error "variant 'variant_fn6' and base 'bar6' have incompatible types" "" { target *-*-* } .-2 } */
65
66
67 void variant_fn7(int *, int, omp_interop_t, omp_interop_t);
68 #pragma omp declare variant(variant_fn7) match(construct={dispatch}) append_args(interop(target))
69 void bar7();
70 /* { dg-error "variant 'variant_fn7' and base 'bar7' have incompatible types" "" { target *-*-* } .-2 } */