Dear all,
some compilers support using "q" to indicate quad precision, e.g.
"4.0q0". Since GCC 4.7, gfortran supports this vendor extension in the
source code. However, READing the floating-point number "4.0q0" was not
supported.
The attached patch adds this support, which some users expect (cf. PR
and comp.lang.fortran).
Testing other compilers, the result is:
- 'q' not supported: g95, NAG f95, PGI, PathScale, Crayftn
- 'q' supported: g77, ifort, sunf95
(I don't know which of those compilers support quad precision.)
Hence, I am not sure whether one should add support for it. What do you
think?
Attached is a lightly tested patch and a test case.
OK for the trunk after regtesting it?
Tobias
! { dg-run }
!
! PR libgfortran/53051
!
! Check that reading "4.0q0" works, i.e. floating-point
! numbers which use "q" to indicate the exponential.
! (Which is a vendor extension.)
!
character(len=20) :: str
real :: r
integer :: i
r = 0
str = '1.0q0'
read(str, *, iostat=i) r
if (r /= 1.0 .or. i /= 0) call abort()
!print *, r
end
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 2024fcd..4d2ce79 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -1136,6 +1136,8 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length)
case 'E':
case 'd':
case 'D':
+ case 'q':
+ case 'Q':
push_char (dtp, 'e');
goto exp1;
@@ -1449,6 +1451,8 @@ read_real (st_parameter_dt *dtp, void * dest, int length)
case 'e':
case 'D':
case 'd':
+ case 'Q':
+ case 'q':
goto exp1;
case '+':
@@ -1546,6 +1550,8 @@ read_real (st_parameter_dt *dtp, void * dest, int length)
case 'e':
case 'D':
case 'd':
+ case 'Q':
+ case 'q':
goto exp1;
case '+':
diff --git a/libgfortran/io/read.c b/libgfortran/io/read.c
index aa41bc7..32c8b32 100644
--- a/libgfortran/io/read.c
+++ b/libgfortran/io/read.c
@@ -1026,6 +1026,8 @@ found_digit:
case 'E':
case 'd':
case 'D':
+ case 'q':
+ case 'Q':
++p;
--w;
goto exponent;