| 1 |
! { dg-do run } |
| 2 |
! { dg-options "-cpp -fdec-format-defaults" } |
| 3 |
! |
| 4 |
! Test case for the default field widths enabled by the -fdec-format-defaults flag. |
| 5 |
! |
| 6 |
! This feature is not part of any Fortran standard, but it is supported by the |
| 7 |
! Oracle Fortran compiler and others. |
| 8 |
! |
| 9 |
! Test case added by Mark Eggleston <[email protected]> to check |
| 10 |
! use of -fdec-format-defaults |
| 11 |
! |
| 12 |
|
| 13 |
program test |
| 14 |
implicit none |
| 15 |
character(50) :: buffer |
| 16 |
|
| 17 |
real(4) :: real_4 |
| 18 |
real(8) :: real_8 |
| 19 |
#ifdef __GFC_REAL_16__ |
| 20 |
real(16) :: real_16 |
| 21 |
#endif |
| 22 |
integer :: len |
| 23 |
character(*), parameter :: fmt = "(A, F, A)" |
| 24 |
|
| 25 |
real_4 = 4.18 |
| 26 |
write(buffer, fmt) ':',real_4,':' |
| 27 |
print *,buffer |
| 28 |
if (buffer.ne.": 4.1799998:") stop 1 |
| 29 |
|
| 30 |
real_4 = 0.00000018 |
| 31 |
write(buffer, fmt) ':',real_4,':' |
| 32 |
print *,buffer |
| 33 |
if (buffer.ne.": 0.0000002:") stop 2 |
| 34 |
|
| 35 |
real_8 = 4.18 |
| 36 |
write(buffer, fmt) ':',real_8,':' |
| 37 |
print *,buffer |
| 38 |
len = len_trim(buffer) |
| 39 |
if (len /= 27) stop 3 |
| 40 |
|
| 41 |
#ifdef __GFC_REAL_16__ |
| 42 |
real_16 = 4.18 |
| 43 |
write(buffer, fmt) ':',real_16,':' |
| 44 |
print *,buffer |
| 45 |
len = len_trim(buffer) |
| 46 |
if (len /= 44) stop 4 |
| 47 |
#endif |
| 48 |
end |