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