[gfortran] Fix PR 17941 (3rd attempt)
Paul Brook
paul@codesourcery.com
Sun Jan 23 22:36:00 GMT 2005
On Saturday 22 January 2005 01:31, Steve Kargl wrote:
> Here's a third patch that fixes fortran/17941. I've
> included 2 testsuite programs. Bootstrapped and
> regtested on amd64-*-freebsd6.0
This still doesn't handle signed integer or real constants consistently.
I decided that match_const_complex_part wasn't worth the effort, besides which
it was incorrect.
The f95 standard (section 4.3.1.3 "Complex type") says that complex constants
with integer type components have the same type kind as the real typed
component, or default complex kind type if both components have integer type.
The existing code parsed (1_8, 1.0_4) as a complex(8) constant, it should be
complex(4).
Tested on i686-linux.
Applied to mainline.
Paul
2004-01-23 Paul Brook <paul@codesourcery.com>
Steven G. Kargl <kargls@comcast.net>
PR fortran/17941
* arith.c (gfc_convert_real): Remove sign handling.
* primary.c (match_digits): Allow whitespace after initial sign.
(match_real_const): Handle signs here. Allow whitespace after
initial sign. Remove dead code.
(match_const_complex_part): Remove.
(match_complex_part): Use match_{real,integer}_const.
(match_complex_constant): Cross-promote integer types.
testsuite/
* gfortran.dg/real_const_1.f: New test.
* gfortran.dg/real_const_2.f90: New test.
* gfortran.dg/complex_int_1.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.complex_const
Type: text/x-diff
Size: 7940 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050123/1aad1653/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: real_const_1.f
Type: application/octet-stream
Size: 917 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050123/1aad1653/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: real_const_2.f90
Type: text/x-csrc
Size: 836 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050123/1aad1653/attachment-0001.bin>
-------------- next part --------------
! { dg-do compile }
! Complex constants with integer components should take ther kind from
! the real typed component, or default complex type if both components have
! integer type.
program prog
call test1 ((1_8, 1.0_4))
call test2 ((1_8, 2_8))
contains
subroutine test1(x)
complex(4) :: x
end subroutine
subroutine test2(x)
complex :: x
end subroutine
end program
More information about the Fortran
mailing list