1 // PR c++/38348
2 // { dg-do run }
3
4 extern "C" void abort ();
5 int cnt;
6
7 template <typename T>
8 void
f0(T,int)9 f0 (T, int)
10 {
11 abort ();
12 }
13
14 template <>
15 void
16 f0<int> (int, int type)
17 {
18 if (type != 0)
19 abort ();
20 #pragma omp atomic
21 cnt++;
22 }
23
24 template <>
25 void
26 f0<const char *> (const char *, int type)
27 {
28 if (type != 1)
29 abort ();
30 #pragma omp atomic
31 cnt++;
32 }
33
34 template <typename T>
35 void
f1()36 f1 ()
37 {
38 #pragma omp parallel for
39 for (int i = 0; i < 10; i++)
40 f0 (i, 0);
41 }
42
43 template <typename T>
44 void
f2()45 f2 ()
46 {
47 #pragma omp parallel for
48 for (T i = T (0); i < T (10); i += T (1))
49 f0 (i, 0);
50 }
51
52 void
f3()53 f3 ()
54 {
55 #pragma omp parallel for
56 for (int i = 0; i < 10; i++)
57 f0 (i, 0);
58 }
59
60 const char *p = "abcdefghij";
61
62 template <typename T>
63 void
f4()64 f4 ()
65 {
66 #pragma omp parallel for
67 for (const char *i = p; i < p + 10; i += 1)
68 f0 (i, 1);
69 }
70
71 template <typename T>
72 void
f5()73 f5 ()
74 {
75 #pragma omp parallel for
76 for (T i = T (p); i < T (p + 10); i += 1)
77 f0 (i, 1);
78 }
79
80 void
f6()81 f6 ()
82 {
83 #pragma omp parallel for
84 for (const char *i = p; i < p + 10; i++)
85 f0 (i, 1);
86 }
87
88 int
main()89 main ()
90 {
91 f1<int> ();
92 if (cnt != 10)
93 abort ();
94 f2<int> ();
95 if (cnt != 20)
96 abort ();
97 f3 ();
98 if (cnt != 30)
99 abort ();
100 f4<int> ();
101 if (cnt != 40)
102 abort ();
103 f5<const char *> ();
104 if (cnt != 50)
105 abort ();
106 f6 ();
107 if (cnt != 60)
108 abort ();
109 }
110