1 // RUN: %libomptarget-compile-generic && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-generic 2>&1 | %fcheck-generic -allow-empty -check-prefix=DEBUG
2 // REQUIRES: libomptarget-debug
3 
4 /*
5   Test for the 'requires' clause check.
6   When a target region is used, the requires flags are set in the
7   runtime for the entire compilation unit. If the flags are set again,
8   (for whatever reason) the set must be consistent with previously
9   set values.
10 */
11 #include <stdio.h>
12 #include <omp.h>
13 
14 // ---------------------------------------------------------------------------
15 // Various definitions copied from OpenMP RTL
16 
17 extern void __tgt_register_requires(int64_t);
18 
19 // End of definitions copied from OpenMP RTL.
20 // ---------------------------------------------------------------------------
21 
22 void run_reg_requires() {
23   // Before the target region is registered, the requires registers the status
24   // of the requires clauses. Since there are no requires clauses in this file
25   // the flags state can only be OMP_REQ_NONE i.e. 1.
26 
27   // This is the 2nd time this function is called so it should print the debug
28   // info belonging to the check.
29   __tgt_register_requires(1);
30   __tgt_register_requires(1);
31   // DEBUG: New requires flags 1 compatible with existing 1!
32 }
33 
34 // ---------------------------------------------------------------------------
35 int main() {
36   run_reg_requires();
37 
38 // This also runs reg requires for the first time.
39 #pragma omp target
40   {}
41 
42   return 0;
43 }
44