From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7191 invoked by alias); 31 Jul 2007 20:32:17 -0000 Received: (qmail 7171 invoked by uid 22791); 31 Jul 2007 20:32:15 -0000 X-Spam-Check-By: sourceware.org Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.208.78.105) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 31 Jul 2007 20:32:11 +0000 Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.1/8.14.1) with ESMTP id l6VKW1Ca030039; Tue, 31 Jul 2007 13:32:01 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.1/8.14.1/Submit) id l6VKVvjZ030038; Tue, 31 Jul 2007 13:31:57 -0700 (PDT) (envelope-from sgk) Date: Tue, 31 Jul 2007 20:52:00 -0000 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH,fortran/32942] Give EXPONENT the correct return type Message-ID: <20070731203157.GA30019@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="5mCyUwZo2JvN/JJP" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-07/txt/msg02204.txt.bz2 --5mCyUwZo2JvN/JJP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 502 The library routines for EXPONENT return a INTEGER(4) value. When -fdefault-integer-8 is used, the result needs to be convert to the correct type. The attach patch, regression tested on amd64-*-freebsd, does the trick. OK for trunk? 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. -- Steve --5mCyUwZo2JvN/JJP Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pr32942.diff" Content-length: 1421 Index: testsuite/gfortran.dg/exponent_2.f90 =================================================================== --- testsuite/gfortran.dg/exponent_2.f90 (revision 0) +++ testsuite/gfortran.dg/exponent_2.f90 (revision 0) @@ -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 Index: fortran/trans-intrinsic.c =================================================================== --- fortran/trans-intrinsic.c (revision 127065) +++ fortran/trans-intrinsic.c (working copy) @@ -718,9 +718,9 @@ gfc_conv_intrinsic_lib_function (gfc_se /* 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 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. */ --5mCyUwZo2JvN/JJP--