From 14b1261a5b25da80aa1cbc2936397b472c7928d1 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Tue, 31 Jul 2007 20:48:21 +0000 Subject: re PR fortran/32942 (Wrong code with with -fdefault-integer-8) 2007-07-31 Steven G. Kargl PR fortran/32942 * gfortran.dg/exponent_2.f90: New test. 2007-07-31 Steven G. Kargl PR fortran/32942 *trans-intrinsic.c (gfc_conv_intrinsic_exponent): Convert to correct type. From-SVN: r127105 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/trans-intrinsic.c | 10 +++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/exponent_2.f90 | 11 +++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/exponent_2.f90 (limited to 'gcc') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6fda297..ce3e62c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2007-07-31 Steven G. Kargl + + PR fortran/32942 + *trans-intrinsic.c (gfc_conv_intrinsic_exponent): Convert to correct + type. + 2007-07-29 Jerry DeLisle * invoke.texi: Document -fsign-zero flag. diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 8f57ae1..578cd7f 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -718,9 +718,9 @@ gfc_conv_intrinsic_lib_function (gfc_se * se, gfc_expr * expr) /* Generate code for EXPONENT(X) intrinsic function. */ static void -gfc_conv_intrinsic_exponent (gfc_se * se, gfc_expr * expr) +gfc_conv_intrinsic_exponent (gfc_se *se, gfc_expr *expr) { - tree arg, fndecl; + tree arg, fndecl, type; gfc_expr *a1; gfc_conv_intrinsic_function_args (se, expr, &arg, 1); @@ -744,7 +744,9 @@ gfc_conv_intrinsic_exponent (gfc_se * se, gfc_expr * expr) gcc_unreachable (); } - se->expr = build_call_expr (fndecl, 1, arg); + /* Convert it to the required type. */ + type = gfc_typenode_for_spec (&expr->ts); + se->expr = fold_convert (type, build_call_expr (fndecl, 1, arg)); } /* Evaluate a single upper or lower bound. */ @@ -2527,7 +2529,9 @@ gfc_conv_intrinsic_ishft (gfc_se * se, gfc_expr * expr) build_int_cst (type, 0), tmp); } + /* Circular shift. AKA rotate or barrel shift. */ + static void gfc_conv_intrinsic_ishftc (gfc_se * se, gfc_expr * expr) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 24c0d4b..4990638 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-07-31 Steven G. Kargl + + PR fortran/32942 + * gfortran.dg/exponent_2.f90: New test. + 2007-07-30 Jan Sjodin * gcc.dg/vect/vect-117.c: New test. diff --git a/gcc/testsuite/gfortran.dg/exponent_2.f90 b/gcc/testsuite/gfortran.dg/exponent_2.f90 new file mode 100644 index 0000000..1b91706 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/exponent_2.f90 @@ -0,0 +1,11 @@ +! { dg-do run } +! { dg-options "-fdefault-integer-8" } +! PR fortran/32942 +! Testcase contributed by Dominique d'Humieres . +integer i +real x +x = 3.0 +if (2 /= exponent(x)) call abort +i = exponent (x) +if (i /= 2) call abort +end -- cgit v1.1