1 /* { dg-set-target-env-var OMP_TARGET_OFFLOAD "mandatory" } */
2 
3 #include <omp.h>
4 #include <stdlib.h>
5 
6 int v;
7 
8 void
foo(void)9 foo (void)
10 {
11   v++;
12 }
13 
14 #pragma omp declare target to (v, foo)
15 
16 int
main()17 main ()
18 {
19   /* OMP_TARGET_OFFLOAD=mandatory shouldn't fail for host fallback
20      if it is because the program explicitly asked for the host
21      fallback through if(false) or omp_get_initial_device () as
22      the device.  */
23   #pragma omp target if (v)
24   foo ();
25   #pragma omp target device (omp_get_initial_device ())
26   foo ();
27   omp_set_default_device (omp_get_initial_device ());
28   #pragma omp target
29   foo ();
30   if (v != 3)
31     abort ();
32   return 0;
33 }
34