PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.hsa.c / switch-1.c
bloba180cf6cb7bcadae5d029b7f7d0f34b0ed1a10e7
1 #include <assert.h>
3 #define s 100
5 #pragma omp declare target
6 int
7 switch1 (int a)
9 switch (a)
11 case 1:
12 return 11;
13 case 33:
14 return 333;
15 case 55:
16 return 55;
17 default:
18 return -1;
22 int
23 switch2 (int a)
25 switch (a)
27 case 1 ... 11:
28 return 11;
29 break;
30 case 33:
31 return 333;
32 break;
33 case 55:
34 return 55;
35 break;
36 default:
37 return -1;
41 int
42 switch3 (int a)
44 switch (a)
46 case 1 ... 11:
47 return 11;
48 case 12 ... 22:
49 return 22;
50 case 23 ... 33:
51 return 33;
52 case 34 ... 44:
53 return 44;
54 default:
55 return 44;
59 int
60 switch4 (int a, int b)
62 switch (a)
64 case 1 ... 11:
65 return a;
66 case 12 ... 22:
67 return b;
68 case 23 ... 33:
69 return a;
70 case 34 ... 44:
71 return b;
72 default:
73 return 12345;
77 int
78 switch5 (int a, int b)
80 switch (a)
82 case 1 ... 2:
83 return 1;
84 case 3 ... 4:
85 return 2;
86 case 5 ... 6:
87 return 3;
88 case 7 ... 11:
89 return 4;
92 return -1;
94 #pragma omp end declare target
96 int
97 main (int argc)
99 int array[s];
101 #pragma omp target map(tofrom : array[:s])
103 for (int i = 0; i < s; i++)
104 array[i] = switch1 (i);
107 for (int i = 0; i < s; i++)
108 assert (array[i] == switch1 (i));
110 #pragma omp target map(tofrom : array[:s])
112 for (int i = 0; i < s; i++)
113 array[i] = switch2 (i);
116 for (int i = 0; i < s; i++)
117 assert (array[i] == switch2 (i));
119 #pragma omp target map(tofrom : array[:s])
121 for (int i = 0; i < s; i++)
122 array[i] = switch3 (i);
125 for (int i = 0; i < s; i++)
126 assert (array[i] == switch3 (i));
128 #pragma omp target map(tofrom : array[:s])
130 for (int i = 0; i < s; i++)
131 array[i] = switch4 (i, i + 1);
134 for (int i = 0; i < s; i++)
135 assert (array[i] == switch4 (i, i + 1));
137 #pragma omp target map(tofrom : array[:s])
139 for (int i = 0; i < s; i++)
140 array[i] = switch5 (i, i + 1);
143 for (int i = 0; i < s; i++)
144 assert (array[i] == switch5 (i, i + 1));