This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch,fortran] Accept noninteger exponents in initialization expressions for Fortran 2003 (PR29962)
- From: Tobias Burnus <burnus at net-b dot de>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 04 Dec 2006 20:22:02 +0100
- Subject: Re: [patch,fortran] Accept noninteger exponents in initialization expressions for Fortran 2003 (PR29962)
- References: <456AB9F8.1060801@net-b.de> <45747367.8070007@net-b.de>
... and now with patch.
Tobias Burnus wrote:
> This is a rather trivial change. Anyone wanting to approve it?
> It is identically to the one submitted one week ago, except that I
> decided now to add also a test case.
> (Before it was also rejected in the GNU mode.)
>
> Regtested on x86_64-unknown-linux-gnu. Ok for the trunk (only)?
>
> Tobias
>
>
> Tobias Burnus wrote:
>
>> :ADDPATCH fortran:
>>
>> Fortran 2003 allows much more in initialization expressions than Fortran
>> 95 (cf. PR29962), some of which are support in STD_GNU.
>>
>> This patch allows noninteger exponents in initialization expressions.
>> The relevant parts of the standard are:
>>
>> "7.1.7 Initialization expression" in Fortran 2003 and in the Section
>> "7.1.6.1 Constant expression" in Fortran 95.
>>
>> F95: "An initialization expression is a constant expression in which the
>> exponentiation operation is
>> permitted only with an integer power"
>>
>> In F2003 this clause is gone.
>>
>> Regression tested on x86_64-unknown-linux-gnu.
>>
>> Tobias
>>
>> 2006-11-27 Tobias Burnus <burnus@net-b.de>
>>
>> PR fortran/29962
>> * expr.c (check_intrinsic_op): Allow noninteger exponents for F2003.
>>
>>
> testsuite/
> 2006-12-04 Tobias Burnus <burnus@net-b.de>
>
> PR fortran/29962
> * initialization_4.f90: Test noninteger exponents (-std=f95).
> * initialization_5.f90: New test for noninteger exponents with -std=f2003
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (Revision 119497)
+++ gcc/fortran/expr.c (Arbeitskopie)
@@ -1622,8 +1623,10 @@
if (e->value.op.operator == INTRINSIC_POWER
&& check_function == check_init_expr && et0 (op2) != BT_INTEGER)
{
- gfc_error ("Exponent at %L must be INTEGER for an initialization "
- "expression", &op2->where);
+ if (gfc_notify_std (GFC_STD_F2003,"Fortran 2003: Noninteger "
+ "exponent in an initialization "
+ "expression at %L", &op2->where)
+ == FAILURE)
return FAILURE;
}
Index: gcc/testsuite/gfortran.dg/initialization_4.f90
===================================================================
--- gcc/testsuite/gfortran.dg/initialization_4.f90 (Revision 119497)
+++ gcc/testsuite/gfortran.dg/initialization_4.f90 (Arbeitskopie)
@@ -3,4 +3,5 @@
! { dg-do compile }
! { dg-options "-std=f95" }
real, parameter :: pi = 4.0*Atan(1.0) ! { dg-error "Evaluation of nonstandard initialization expression" }
+real, parameter :: three = 27.0**(1.0/3.0) ! { dg-error "Noninteger exponent in an initialization expression" }
end
Index: gcc/testsuite/gfortran.dg/initialization_5.f90
===================================================================
--- gcc/testsuite/gfortran.dg/initialization_5.f90 (Revision 0)
+++ gcc/testsuite/gfortran.dg/initialization_5.f90 (Revision 0)
@@ -0,0 +1,7 @@
+! initialization expression, now allowed in Fortran 2003
+! PR fortran/29962
+! { dg-do run }
+! { dg-options "-std=f2003 -fall-intrinsics" }
+ real, parameter :: three = 27.0**(1.0/3.0)
+ if(abs(three-3.0)>epsilon(three)) call abort()
+end