From 3d1f465aff3484eafd4e10e38bc7f7331a43d0dd Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sun, 4 Mar 2007 08:03:34 +0000 Subject: [PATCH] re PR fortran/30981 ([4.1 only] a ** exp fails for integer exponents if exp is "-huge()-1" (endless loop)) 2007-03-04 Thomas Koenig PR libfortran/30981 * m4/pow_m4: Use appropriate unsigned int type for u. * generated/pow_c10_i16.c: Regenerated. * generated/pow_c10_i4.c: Regenerated. * generated/pow_c10_i8.c: Regenerated. * generated/pow_c16_i16.c: Regenerated. * generated/pow_c16_i4.c: Regenerated. * generated/pow_c16_i8.c: Regenerated. * generated/pow_c4_i16.c: Regenerated. * generated/pow_c4_i4.c: Regenerated. * generated/pow_c4_i8.c: Regenerated. * generated/pow_c8_i16.c: Regenerated. * generated/pow_c8_i4.c: Regenerated. * generated/pow_c8_i8.c: Regenerated. * generated/pow_i16_i16.c: Regenerated. * generated/pow_i16_i4.c: Regenerated. * generated/pow_i16_i8.c: Regenerated. * generated/pow_i4_i16.c: Regenerated. * generated/pow_i4_i4.c: Regenerated. * generated/pow_i4_i8.c: Regenerated. * generated/pow_i8_i16.c: Regenerated. * generated/pow_i8_i4.c: Regenerated. * generated/pow_i8_i8.c: Regenerated. * generated/pow_r10_i16.c: Regenerated. * generated/pow_r10_i4.c: Regenerated. * generated/pow_r10_i8.c: Regenerated. * generated/pow_r16_i16.c: Regenerated. * generated/pow_r16_i4.c: Regenerated. * generated/pow_r16_i8.c: Regenerated. * generated/pow_r4_i16.c: Regenerated. * generated/pow_r4_i4.c: Regenerated. * generated/pow_r4_i8.c: Regenerated. * generated/pow_r8_i16.c: Regenerated. * generated/pow_r8_i4.c: Regenerated. * generated/pow_r8_i8.c: Regenerated. 2007-03-04 Thomas Koenig PR libfortran/30981 * gfortran.dg/integer_exponentiation_1.f90: New test. From-SVN: r122522 --- gcc/testsuite/ChangeLog | 5 +++ .../gfortran.dg/integer_exponentiation_1.f90 | 6 +++ libgfortran/ChangeLog | 38 +++++++++++++++++++ libgfortran/generated/pow_c10_i16.c | 10 +++-- libgfortran/generated/pow_c10_i4.c | 10 +++-- libgfortran/generated/pow_c10_i8.c | 10 +++-- libgfortran/generated/pow_c16_i16.c | 10 +++-- libgfortran/generated/pow_c16_i4.c | 10 +++-- libgfortran/generated/pow_c16_i8.c | 10 +++-- libgfortran/generated/pow_c4_i16.c | 10 +++-- libgfortran/generated/pow_c4_i4.c | 10 +++-- libgfortran/generated/pow_c4_i8.c | 10 +++-- libgfortran/generated/pow_c8_i16.c | 10 +++-- libgfortran/generated/pow_c8_i4.c | 10 +++-- libgfortran/generated/pow_c8_i8.c | 10 +++-- libgfortran/generated/pow_i16_i16.c | 8 +++- libgfortran/generated/pow_i16_i4.c | 8 +++- libgfortran/generated/pow_i16_i8.c | 8 +++- libgfortran/generated/pow_i4_i16.c | 8 +++- libgfortran/generated/pow_i4_i4.c | 8 +++- libgfortran/generated/pow_i4_i8.c | 8 +++- libgfortran/generated/pow_i8_i16.c | 8 +++- libgfortran/generated/pow_i8_i4.c | 8 +++- libgfortran/generated/pow_i8_i8.c | 8 +++- libgfortran/generated/pow_r10_i16.c | 10 +++-- libgfortran/generated/pow_r10_i4.c | 10 +++-- libgfortran/generated/pow_r10_i8.c | 10 +++-- libgfortran/generated/pow_r16_i16.c | 10 +++-- libgfortran/generated/pow_r16_i4.c | 10 +++-- libgfortran/generated/pow_r16_i8.c | 10 +++-- libgfortran/generated/pow_r4_i16.c | 10 +++-- libgfortran/generated/pow_r4_i4.c | 10 +++-- libgfortran/generated/pow_r4_i8.c | 10 +++-- libgfortran/generated/pow_r8_i16.c | 10 +++-- libgfortran/generated/pow_r8_i4.c | 10 +++-- libgfortran/generated/pow_r8_i8.c | 10 +++-- libgfortran/m4/pow.m4 | 10 +++-- 37 files changed, 278 insertions(+), 93 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/integer_exponentiation_1.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 097016dec5b..309ea4ac6e9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-03-04 Thomas Koenig + + PR libfortran/30981 + * gfortran.dg/integer_exponentiation_1.f90: New test. + 2007-03-04 Nathan Sidwell * gcc.target/m68k/m68k.exp: New. diff --git a/gcc/testsuite/gfortran.dg/integer_exponentiation_1.f90 b/gcc/testsuite/gfortran.dg/integer_exponentiation_1.f90 new file mode 100644 index 00000000000..57d7466d005 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/integer_exponentiation_1.f90 @@ -0,0 +1,6 @@ +! { dg-do run } +! PR 30981 - this used to go into an endless loop during execution. +program test + a = 3.0 + b = a**(-2147483647-1) ! { dg-warning "Integer outside symmetric range" } +end program test diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index cfa42b23db4..ad71a7e6b20 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,41 @@ +2007-03-04 Thomas Koenig + + PR libfortran/30981 + * m4/pow_m4: Use appropriate unsigned int type for u. + * generated/pow_c10_i16.c: Regenerated. + * generated/pow_c10_i4.c: Regenerated. + * generated/pow_c10_i8.c: Regenerated. + * generated/pow_c16_i16.c: Regenerated. + * generated/pow_c16_i4.c: Regenerated. + * generated/pow_c16_i8.c: Regenerated. + * generated/pow_c4_i16.c: Regenerated. + * generated/pow_c4_i4.c: Regenerated. + * generated/pow_c4_i8.c: Regenerated. + * generated/pow_c8_i16.c: Regenerated. + * generated/pow_c8_i4.c: Regenerated. + * generated/pow_c8_i8.c: Regenerated. + * generated/pow_i16_i16.c: Regenerated. + * generated/pow_i16_i4.c: Regenerated. + * generated/pow_i16_i8.c: Regenerated. + * generated/pow_i4_i16.c: Regenerated. + * generated/pow_i4_i4.c: Regenerated. + * generated/pow_i4_i8.c: Regenerated. + * generated/pow_i8_i16.c: Regenerated. + * generated/pow_i8_i4.c: Regenerated. + * generated/pow_i8_i8.c: Regenerated. + * generated/pow_r10_i16.c: Regenerated. + * generated/pow_r10_i4.c: Regenerated. + * generated/pow_r10_i8.c: Regenerated. + * generated/pow_r16_i16.c: Regenerated. + * generated/pow_r16_i4.c: Regenerated. + * generated/pow_r16_i8.c: Regenerated. + * generated/pow_r4_i16.c: Regenerated. + * generated/pow_r4_i4.c: Regenerated. + * generated/pow_r4_i8.c: Regenerated. + * generated/pow_r8_i16.c: Regenerated. + * generated/pow_r8_i4.c: Regenerated. + * generated/pow_r8_i8.c: Regenerated. + 2007-03-03 Francois-Xavier Coudert PR libfortran/31001 diff --git a/libgfortran/generated/pow_c10_i16.c b/libgfortran/generated/pow_c10_i16.c index 6332013bdbc..c62d5f47c22 100644 --- a/libgfortran/generated/pow_c10_i16.c +++ b/libgfortran/generated/pow_c10_i16.c @@ -45,7 +45,8 @@ GFC_COMPLEX_10 pow_c10_i16 (GFC_COMPLEX_10 a, GFC_INTEGER_16 b) { GFC_COMPLEX_10 pow, x; - GFC_INTEGER_16 n, u; + GFC_INTEGER_16 n; + GFC_UINTEGER_16 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c10_i16 (GFC_COMPLEX_10 a, GFC_INTEGER_16 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_c10_i4.c b/libgfortran/generated/pow_c10_i4.c index ccb1a0c6a2b..aca3e7f1ad7 100644 --- a/libgfortran/generated/pow_c10_i4.c +++ b/libgfortran/generated/pow_c10_i4.c @@ -45,7 +45,8 @@ GFC_COMPLEX_10 pow_c10_i4 (GFC_COMPLEX_10 a, GFC_INTEGER_4 b) { GFC_COMPLEX_10 pow, x; - GFC_INTEGER_4 n, u; + GFC_INTEGER_4 n; + GFC_UINTEGER_4 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c10_i4 (GFC_COMPLEX_10 a, GFC_INTEGER_4 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_c10_i8.c b/libgfortran/generated/pow_c10_i8.c index 0f2b2426481..a4a94526db4 100644 --- a/libgfortran/generated/pow_c10_i8.c +++ b/libgfortran/generated/pow_c10_i8.c @@ -45,7 +45,8 @@ GFC_COMPLEX_10 pow_c10_i8 (GFC_COMPLEX_10 a, GFC_INTEGER_8 b) { GFC_COMPLEX_10 pow, x; - GFC_INTEGER_8 n, u; + GFC_INTEGER_8 n; + GFC_UINTEGER_8 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c10_i8 (GFC_COMPLEX_10 a, GFC_INTEGER_8 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_c16_i16.c b/libgfortran/generated/pow_c16_i16.c index a6d888369b2..d05580f71d6 100644 --- a/libgfortran/generated/pow_c16_i16.c +++ b/libgfortran/generated/pow_c16_i16.c @@ -45,7 +45,8 @@ GFC_COMPLEX_16 pow_c16_i16 (GFC_COMPLEX_16 a, GFC_INTEGER_16 b) { GFC_COMPLEX_16 pow, x; - GFC_INTEGER_16 n, u; + GFC_INTEGER_16 n; + GFC_UINTEGER_16 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c16_i16 (GFC_COMPLEX_16 a, GFC_INTEGER_16 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_c16_i4.c b/libgfortran/generated/pow_c16_i4.c index d3960520cf9..b0576c5ad44 100644 --- a/libgfortran/generated/pow_c16_i4.c +++ b/libgfortran/generated/pow_c16_i4.c @@ -45,7 +45,8 @@ GFC_COMPLEX_16 pow_c16_i4 (GFC_COMPLEX_16 a, GFC_INTEGER_4 b) { GFC_COMPLEX_16 pow, x; - GFC_INTEGER_4 n, u; + GFC_INTEGER_4 n; + GFC_UINTEGER_4 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c16_i4 (GFC_COMPLEX_16 a, GFC_INTEGER_4 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_c16_i8.c b/libgfortran/generated/pow_c16_i8.c index 0a0e94d0613..3d991606a40 100644 --- a/libgfortran/generated/pow_c16_i8.c +++ b/libgfortran/generated/pow_c16_i8.c @@ -45,7 +45,8 @@ GFC_COMPLEX_16 pow_c16_i8 (GFC_COMPLEX_16 a, GFC_INTEGER_8 b) { GFC_COMPLEX_16 pow, x; - GFC_INTEGER_8 n, u; + GFC_INTEGER_8 n; + GFC_UINTEGER_8 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c16_i8 (GFC_COMPLEX_16 a, GFC_INTEGER_8 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_c4_i16.c b/libgfortran/generated/pow_c4_i16.c index 1085ad21caf..84309ff63bd 100644 --- a/libgfortran/generated/pow_c4_i16.c +++ b/libgfortran/generated/pow_c4_i16.c @@ -45,7 +45,8 @@ GFC_COMPLEX_4 pow_c4_i16 (GFC_COMPLEX_4 a, GFC_INTEGER_16 b) { GFC_COMPLEX_4 pow, x; - GFC_INTEGER_16 n, u; + GFC_INTEGER_16 n; + GFC_UINTEGER_16 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c4_i16 (GFC_COMPLEX_4 a, GFC_INTEGER_16 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_c4_i4.c b/libgfortran/generated/pow_c4_i4.c index ca376710fba..35597d0df16 100644 --- a/libgfortran/generated/pow_c4_i4.c +++ b/libgfortran/generated/pow_c4_i4.c @@ -45,7 +45,8 @@ GFC_COMPLEX_4 pow_c4_i4 (GFC_COMPLEX_4 a, GFC_INTEGER_4 b) { GFC_COMPLEX_4 pow, x; - GFC_INTEGER_4 n, u; + GFC_INTEGER_4 n; + GFC_UINTEGER_4 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c4_i4 (GFC_COMPLEX_4 a, GFC_INTEGER_4 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_c4_i8.c b/libgfortran/generated/pow_c4_i8.c index f9fc849ca19..bb113df2b47 100644 --- a/libgfortran/generated/pow_c4_i8.c +++ b/libgfortran/generated/pow_c4_i8.c @@ -45,7 +45,8 @@ GFC_COMPLEX_4 pow_c4_i8 (GFC_COMPLEX_4 a, GFC_INTEGER_8 b) { GFC_COMPLEX_4 pow, x; - GFC_INTEGER_8 n, u; + GFC_INTEGER_8 n; + GFC_UINTEGER_8 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c4_i8 (GFC_COMPLEX_4 a, GFC_INTEGER_8 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_c8_i16.c b/libgfortran/generated/pow_c8_i16.c index 0fc162b5014..ee4b68e955f 100644 --- a/libgfortran/generated/pow_c8_i16.c +++ b/libgfortran/generated/pow_c8_i16.c @@ -45,7 +45,8 @@ GFC_COMPLEX_8 pow_c8_i16 (GFC_COMPLEX_8 a, GFC_INTEGER_16 b) { GFC_COMPLEX_8 pow, x; - GFC_INTEGER_16 n, u; + GFC_INTEGER_16 n; + GFC_UINTEGER_16 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c8_i16 (GFC_COMPLEX_8 a, GFC_INTEGER_16 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_c8_i4.c b/libgfortran/generated/pow_c8_i4.c index 64b4b3c5b69..30c6007879f 100644 --- a/libgfortran/generated/pow_c8_i4.c +++ b/libgfortran/generated/pow_c8_i4.c @@ -45,7 +45,8 @@ GFC_COMPLEX_8 pow_c8_i4 (GFC_COMPLEX_8 a, GFC_INTEGER_4 b) { GFC_COMPLEX_8 pow, x; - GFC_INTEGER_4 n, u; + GFC_INTEGER_4 n; + GFC_UINTEGER_4 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c8_i4 (GFC_COMPLEX_8 a, GFC_INTEGER_4 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_c8_i8.c b/libgfortran/generated/pow_c8_i8.c index 39a5d6b71e0..d9b658b4fc4 100644 --- a/libgfortran/generated/pow_c8_i8.c +++ b/libgfortran/generated/pow_c8_i8.c @@ -45,7 +45,8 @@ GFC_COMPLEX_8 pow_c8_i8 (GFC_COMPLEX_8 a, GFC_INTEGER_8 b) { GFC_COMPLEX_8 pow, x; - GFC_INTEGER_8 n, u; + GFC_INTEGER_8 n; + GFC_UINTEGER_8 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_c8_i8 (GFC_COMPLEX_8 a, GFC_INTEGER_8 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_i16_i16.c b/libgfortran/generated/pow_i16_i16.c index eda2fb6dc7c..b665f5ea2b9 100644 --- a/libgfortran/generated/pow_i16_i16.c +++ b/libgfortran/generated/pow_i16_i16.c @@ -45,7 +45,8 @@ GFC_INTEGER_16 pow_i16_i16 (GFC_INTEGER_16 a, GFC_INTEGER_16 b) { GFC_INTEGER_16 pow, x; - GFC_INTEGER_16 n, u; + GFC_INTEGER_16 n; + GFC_UINTEGER_16 u; n = b; x = a; @@ -60,7 +61,10 @@ pow_i16_i16 (GFC_INTEGER_16 a, GFC_INTEGER_16 b) return (n & 1) ? -1 : 1; return (x == 0) ? 1 / x : 0; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_i16_i4.c b/libgfortran/generated/pow_i16_i4.c index 6e4d65c35c4..45994a3598e 100644 --- a/libgfortran/generated/pow_i16_i4.c +++ b/libgfortran/generated/pow_i16_i4.c @@ -45,7 +45,8 @@ GFC_INTEGER_16 pow_i16_i4 (GFC_INTEGER_16 a, GFC_INTEGER_4 b) { GFC_INTEGER_16 pow, x; - GFC_INTEGER_4 n, u; + GFC_INTEGER_4 n; + GFC_UINTEGER_4 u; n = b; x = a; @@ -60,7 +61,10 @@ pow_i16_i4 (GFC_INTEGER_16 a, GFC_INTEGER_4 b) return (n & 1) ? -1 : 1; return (x == 0) ? 1 / x : 0; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_i16_i8.c b/libgfortran/generated/pow_i16_i8.c index d1849511a29..80075051553 100644 --- a/libgfortran/generated/pow_i16_i8.c +++ b/libgfortran/generated/pow_i16_i8.c @@ -45,7 +45,8 @@ GFC_INTEGER_16 pow_i16_i8 (GFC_INTEGER_16 a, GFC_INTEGER_8 b) { GFC_INTEGER_16 pow, x; - GFC_INTEGER_8 n, u; + GFC_INTEGER_8 n; + GFC_UINTEGER_8 u; n = b; x = a; @@ -60,7 +61,10 @@ pow_i16_i8 (GFC_INTEGER_16 a, GFC_INTEGER_8 b) return (n & 1) ? -1 : 1; return (x == 0) ? 1 / x : 0; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_i4_i16.c b/libgfortran/generated/pow_i4_i16.c index f515f80359e..abab476830c 100644 --- a/libgfortran/generated/pow_i4_i16.c +++ b/libgfortran/generated/pow_i4_i16.c @@ -45,7 +45,8 @@ GFC_INTEGER_4 pow_i4_i16 (GFC_INTEGER_4 a, GFC_INTEGER_16 b) { GFC_INTEGER_4 pow, x; - GFC_INTEGER_16 n, u; + GFC_INTEGER_16 n; + GFC_UINTEGER_16 u; n = b; x = a; @@ -60,7 +61,10 @@ pow_i4_i16 (GFC_INTEGER_4 a, GFC_INTEGER_16 b) return (n & 1) ? -1 : 1; return (x == 0) ? 1 / x : 0; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_i4_i4.c b/libgfortran/generated/pow_i4_i4.c index 184fe6d986e..e28cf90b116 100644 --- a/libgfortran/generated/pow_i4_i4.c +++ b/libgfortran/generated/pow_i4_i4.c @@ -45,7 +45,8 @@ GFC_INTEGER_4 pow_i4_i4 (GFC_INTEGER_4 a, GFC_INTEGER_4 b) { GFC_INTEGER_4 pow, x; - GFC_INTEGER_4 n, u; + GFC_INTEGER_4 n; + GFC_UINTEGER_4 u; n = b; x = a; @@ -60,7 +61,10 @@ pow_i4_i4 (GFC_INTEGER_4 a, GFC_INTEGER_4 b) return (n & 1) ? -1 : 1; return (x == 0) ? 1 / x : 0; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_i4_i8.c b/libgfortran/generated/pow_i4_i8.c index ae24ceb54c2..51d2e14a808 100644 --- a/libgfortran/generated/pow_i4_i8.c +++ b/libgfortran/generated/pow_i4_i8.c @@ -45,7 +45,8 @@ GFC_INTEGER_4 pow_i4_i8 (GFC_INTEGER_4 a, GFC_INTEGER_8 b) { GFC_INTEGER_4 pow, x; - GFC_INTEGER_8 n, u; + GFC_INTEGER_8 n; + GFC_UINTEGER_8 u; n = b; x = a; @@ -60,7 +61,10 @@ pow_i4_i8 (GFC_INTEGER_4 a, GFC_INTEGER_8 b) return (n & 1) ? -1 : 1; return (x == 0) ? 1 / x : 0; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_i8_i16.c b/libgfortran/generated/pow_i8_i16.c index 456c28a95bd..88713da698e 100644 --- a/libgfortran/generated/pow_i8_i16.c +++ b/libgfortran/generated/pow_i8_i16.c @@ -45,7 +45,8 @@ GFC_INTEGER_8 pow_i8_i16 (GFC_INTEGER_8 a, GFC_INTEGER_16 b) { GFC_INTEGER_8 pow, x; - GFC_INTEGER_16 n, u; + GFC_INTEGER_16 n; + GFC_UINTEGER_16 u; n = b; x = a; @@ -60,7 +61,10 @@ pow_i8_i16 (GFC_INTEGER_8 a, GFC_INTEGER_16 b) return (n & 1) ? -1 : 1; return (x == 0) ? 1 / x : 0; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_i8_i4.c b/libgfortran/generated/pow_i8_i4.c index 8f85a80c81c..6746af33d5b 100644 --- a/libgfortran/generated/pow_i8_i4.c +++ b/libgfortran/generated/pow_i8_i4.c @@ -45,7 +45,8 @@ GFC_INTEGER_8 pow_i8_i4 (GFC_INTEGER_8 a, GFC_INTEGER_4 b) { GFC_INTEGER_8 pow, x; - GFC_INTEGER_4 n, u; + GFC_INTEGER_4 n; + GFC_UINTEGER_4 u; n = b; x = a; @@ -60,7 +61,10 @@ pow_i8_i4 (GFC_INTEGER_8 a, GFC_INTEGER_4 b) return (n & 1) ? -1 : 1; return (x == 0) ? 1 / x : 0; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_i8_i8.c b/libgfortran/generated/pow_i8_i8.c index 8c8f52e5412..3050974036c 100644 --- a/libgfortran/generated/pow_i8_i8.c +++ b/libgfortran/generated/pow_i8_i8.c @@ -45,7 +45,8 @@ GFC_INTEGER_8 pow_i8_i8 (GFC_INTEGER_8 a, GFC_INTEGER_8 b) { GFC_INTEGER_8 pow, x; - GFC_INTEGER_8 n, u; + GFC_INTEGER_8 n; + GFC_UINTEGER_8 u; n = b; x = a; @@ -60,7 +61,10 @@ pow_i8_i8 (GFC_INTEGER_8 a, GFC_INTEGER_8 b) return (n & 1) ? -1 : 1; return (x == 0) ? 1 / x : 0; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r10_i16.c b/libgfortran/generated/pow_r10_i16.c index ad736641adc..2377e67ca51 100644 --- a/libgfortran/generated/pow_r10_i16.c +++ b/libgfortran/generated/pow_r10_i16.c @@ -45,7 +45,8 @@ GFC_REAL_10 pow_r10_i16 (GFC_REAL_10 a, GFC_INTEGER_16 b) { GFC_REAL_10 pow, x; - GFC_INTEGER_16 n, u; + GFC_INTEGER_16 n; + GFC_UINTEGER_16 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r10_i16 (GFC_REAL_10 a, GFC_INTEGER_16 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r10_i4.c b/libgfortran/generated/pow_r10_i4.c index 3f2373243b4..d21869b5d2c 100644 --- a/libgfortran/generated/pow_r10_i4.c +++ b/libgfortran/generated/pow_r10_i4.c @@ -45,7 +45,8 @@ GFC_REAL_10 pow_r10_i4 (GFC_REAL_10 a, GFC_INTEGER_4 b) { GFC_REAL_10 pow, x; - GFC_INTEGER_4 n, u; + GFC_INTEGER_4 n; + GFC_UINTEGER_4 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r10_i4 (GFC_REAL_10 a, GFC_INTEGER_4 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r10_i8.c b/libgfortran/generated/pow_r10_i8.c index 2e99c600bea..5a5ecffdb44 100644 --- a/libgfortran/generated/pow_r10_i8.c +++ b/libgfortran/generated/pow_r10_i8.c @@ -45,7 +45,8 @@ GFC_REAL_10 pow_r10_i8 (GFC_REAL_10 a, GFC_INTEGER_8 b) { GFC_REAL_10 pow, x; - GFC_INTEGER_8 n, u; + GFC_INTEGER_8 n; + GFC_UINTEGER_8 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r10_i8 (GFC_REAL_10 a, GFC_INTEGER_8 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r16_i16.c b/libgfortran/generated/pow_r16_i16.c index 63d6fa886f2..24313c2df2a 100644 --- a/libgfortran/generated/pow_r16_i16.c +++ b/libgfortran/generated/pow_r16_i16.c @@ -45,7 +45,8 @@ GFC_REAL_16 pow_r16_i16 (GFC_REAL_16 a, GFC_INTEGER_16 b) { GFC_REAL_16 pow, x; - GFC_INTEGER_16 n, u; + GFC_INTEGER_16 n; + GFC_UINTEGER_16 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r16_i16 (GFC_REAL_16 a, GFC_INTEGER_16 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r16_i4.c b/libgfortran/generated/pow_r16_i4.c index 949f2371749..3901577ecc7 100644 --- a/libgfortran/generated/pow_r16_i4.c +++ b/libgfortran/generated/pow_r16_i4.c @@ -45,7 +45,8 @@ GFC_REAL_16 pow_r16_i4 (GFC_REAL_16 a, GFC_INTEGER_4 b) { GFC_REAL_16 pow, x; - GFC_INTEGER_4 n, u; + GFC_INTEGER_4 n; + GFC_UINTEGER_4 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r16_i4 (GFC_REAL_16 a, GFC_INTEGER_4 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r16_i8.c b/libgfortran/generated/pow_r16_i8.c index 37649d82cb1..e7233729b48 100644 --- a/libgfortran/generated/pow_r16_i8.c +++ b/libgfortran/generated/pow_r16_i8.c @@ -45,7 +45,8 @@ GFC_REAL_16 pow_r16_i8 (GFC_REAL_16 a, GFC_INTEGER_8 b) { GFC_REAL_16 pow, x; - GFC_INTEGER_8 n, u; + GFC_INTEGER_8 n; + GFC_UINTEGER_8 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r16_i8 (GFC_REAL_16 a, GFC_INTEGER_8 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r4_i16.c b/libgfortran/generated/pow_r4_i16.c index 635e627e9d6..e73794952d7 100644 --- a/libgfortran/generated/pow_r4_i16.c +++ b/libgfortran/generated/pow_r4_i16.c @@ -45,7 +45,8 @@ GFC_REAL_4 pow_r4_i16 (GFC_REAL_4 a, GFC_INTEGER_16 b) { GFC_REAL_4 pow, x; - GFC_INTEGER_16 n, u; + GFC_INTEGER_16 n; + GFC_UINTEGER_16 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r4_i16 (GFC_REAL_4 a, GFC_INTEGER_16 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r4_i4.c b/libgfortran/generated/pow_r4_i4.c index ff0045f913b..5baa4b17f68 100644 --- a/libgfortran/generated/pow_r4_i4.c +++ b/libgfortran/generated/pow_r4_i4.c @@ -45,7 +45,8 @@ GFC_REAL_4 pow_r4_i4 (GFC_REAL_4 a, GFC_INTEGER_4 b) { GFC_REAL_4 pow, x; - GFC_INTEGER_4 n, u; + GFC_INTEGER_4 n; + GFC_UINTEGER_4 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r4_i4 (GFC_REAL_4 a, GFC_INTEGER_4 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r4_i8.c b/libgfortran/generated/pow_r4_i8.c index 8c6b2ba285f..0aae60a7d45 100644 --- a/libgfortran/generated/pow_r4_i8.c +++ b/libgfortran/generated/pow_r4_i8.c @@ -45,7 +45,8 @@ GFC_REAL_4 pow_r4_i8 (GFC_REAL_4 a, GFC_INTEGER_8 b) { GFC_REAL_4 pow, x; - GFC_INTEGER_8 n, u; + GFC_INTEGER_8 n; + GFC_UINTEGER_8 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r4_i8 (GFC_REAL_4 a, GFC_INTEGER_8 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r8_i16.c b/libgfortran/generated/pow_r8_i16.c index 9fdcf7592e4..e527f3a7a1e 100644 --- a/libgfortran/generated/pow_r8_i16.c +++ b/libgfortran/generated/pow_r8_i16.c @@ -45,7 +45,8 @@ GFC_REAL_8 pow_r8_i16 (GFC_REAL_8 a, GFC_INTEGER_16 b) { GFC_REAL_8 pow, x; - GFC_INTEGER_16 n, u; + GFC_INTEGER_16 n; + GFC_UINTEGER_16 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r8_i16 (GFC_REAL_8 a, GFC_INTEGER_16 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r8_i4.c b/libgfortran/generated/pow_r8_i4.c index a6afcbe6eb4..8da3b81fdff 100644 --- a/libgfortran/generated/pow_r8_i4.c +++ b/libgfortran/generated/pow_r8_i4.c @@ -45,7 +45,8 @@ GFC_REAL_8 pow_r8_i4 (GFC_REAL_8 a, GFC_INTEGER_4 b) { GFC_REAL_8 pow, x; - GFC_INTEGER_4 n, u; + GFC_INTEGER_4 n; + GFC_UINTEGER_4 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r8_i4 (GFC_REAL_8 a, GFC_INTEGER_4 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/generated/pow_r8_i8.c b/libgfortran/generated/pow_r8_i8.c index 3b650f2f073..b858fab3a29 100644 --- a/libgfortran/generated/pow_r8_i8.c +++ b/libgfortran/generated/pow_r8_i8.c @@ -45,7 +45,8 @@ GFC_REAL_8 pow_r8_i8 (GFC_REAL_8 a, GFC_INTEGER_8 b) { GFC_REAL_8 pow, x; - GFC_INTEGER_8 n, u; + GFC_INTEGER_8 n; + GFC_UINTEGER_8 u; n = b; x = a; @@ -55,10 +56,13 @@ pow_r8_i8 (GFC_REAL_8 a, GFC_INTEGER_8 b) if (n < 0) { - n = -n; + u = -n; x = pow / x; } - u = n; + else + { + u = n; + } for (;;) { if (u & 1) diff --git a/libgfortran/m4/pow.m4 b/libgfortran/m4/pow.m4 index ae490040c65..54e2fda03c2 100644 --- a/libgfortran/m4/pow.m4 +++ b/libgfortran/m4/pow.m4 @@ -46,7 +46,8 @@ rtype_name `pow_'rtype_code`_'atype_code (rtype_name a, atype_name b) { rtype_name pow, x; - atype_name n, u; + atype_name n; + `GFC_UINTEGER_'atype_kind` u;' n = b; x = a; @@ -62,11 +63,14 @@ ifelse(rtype_letter,i,`dnl return (n & 1) ? -1 : 1; return (x == 0) ? 1 / x : 0; ',` - n = -n; + u = -n; x = pow / x; ')dnl } - u = n; + else + { + u = n; + } for (;;) { if (u & 1)