re PR fortran/28585 (Fortran 2003: Support NEW_LINE intrinsic)
PR fortran/28585 * intrinsic.c (add_functions): Add new_line Fortran 2003 intrinsic. * intrinsic.h: Add gfc_simplify_new_line and gfc_check_new_line prototypes. * check.c (gfc_check_new_line): New function. * simplify.c (gfc_simplify_new_line): New function. * intrinsic.texi: Document new_line intrinsic. * gfortran.dg/new_line.f90: New test. From-SVN: r117555
This commit is contained in:
parent
3ac25120de
commit
bec93d7937
@ -1,3 +1,13 @@
|
||||
2006-10-08 Tobias Burnus <burnus@net-b.de>
|
||||
|
||||
PR fortran/28585
|
||||
* intrinsic.c (add_functions): Add new_line Fortran 2003 intrinsic.
|
||||
* intrinsic.h: Add gfc_simplify_new_line and gfc_check_new_line
|
||||
prototypes.
|
||||
* check.c (gfc_check_new_line): New function.
|
||||
* simplify.c (gfc_simplify_new_line): New function.
|
||||
* intrinsic.texi: Document new_line intrinsic.
|
||||
|
||||
2006-10-07 Francois-Xavier Coudert <coudert@clipper.ens.fr>
|
||||
|
||||
PR fortran/16580
|
||||
|
@ -1827,6 +1827,14 @@ gfc_check_nearest (gfc_expr * x, gfc_expr * s)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
try
|
||||
gfc_check_new_line (gfc_expr * a)
|
||||
{
|
||||
if (type_check (a, 0, BT_CHARACTER) == FAILURE)
|
||||
return FAILURE;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
try
|
||||
gfc_check_null (gfc_expr * mold)
|
||||
|
@ -1910,6 +1910,10 @@ add_functions (void)
|
||||
|
||||
make_generic ("nearest", GFC_ISYM_NEAREST, GFC_STD_F95);
|
||||
|
||||
add_sym_1 ("new_line", 0, 0, BT_CHARACTER, dc, GFC_STD_F2003,
|
||||
gfc_check_new_line, gfc_simplify_new_line, NULL,
|
||||
i, BT_CHARACTER, dc, REQUIRED);
|
||||
|
||||
add_sym_2 ("nint", 1, 1, BT_INTEGER, di, GFC_STD_F77,
|
||||
gfc_check_a_ikind, gfc_simplify_nint, gfc_resolve_nint,
|
||||
a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di, OPTIONAL);
|
||||
|
@ -98,6 +98,7 @@ try gfc_check_merge (gfc_expr *, gfc_expr *, gfc_expr *);
|
||||
try gfc_check_minloc_maxloc (gfc_actual_arglist *);
|
||||
try gfc_check_minval_maxval (gfc_actual_arglist *);
|
||||
try gfc_check_nearest (gfc_expr *, gfc_expr *);
|
||||
try gfc_check_new_line (gfc_expr *);
|
||||
try gfc_check_null (gfc_expr *);
|
||||
try gfc_check_pack (gfc_expr *, gfc_expr *, gfc_expr *);
|
||||
try gfc_check_precision (gfc_expr *);
|
||||
@ -255,6 +256,7 @@ gfc_expr *gfc_simplify_modulo (gfc_expr *, gfc_expr *);
|
||||
gfc_expr *gfc_simplify_mvbits (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *,
|
||||
gfc_expr *);
|
||||
gfc_expr *gfc_simplify_nearest (gfc_expr *, gfc_expr *);
|
||||
gfc_expr *gfc_simplify_new_line (gfc_expr *);
|
||||
gfc_expr *gfc_simplify_nint (gfc_expr *, gfc_expr *);
|
||||
gfc_expr *gfc_simplify_null (gfc_expr *);
|
||||
gfc_expr *gfc_simplify_idnint (gfc_expr *);
|
||||
|
@ -183,6 +183,7 @@ Some intrinsics have documentation yet to be completed as indicated by 'document
|
||||
* @code{MODULO}: MODULO, Modulo function
|
||||
* @code{MVBITS}: MVBITS, Move bits from one integer to another
|
||||
* @code{NEAREST}: NEAREST, Nearest representable number
|
||||
* @code{NEW_LINE}: NEW_LINE, New line character
|
||||
* @code{NINT}: NINT, Nearest whole number
|
||||
* @code{NOT}: NOT, Logical negation
|
||||
* @code{NULL}: NULL, Function that returns an disassociated pointer
|
||||
@ -5879,6 +5880,45 @@ end program test_nearest
|
||||
|
||||
|
||||
|
||||
@node NEW_LINE
|
||||
@section @code{NEW_LINE} --- New line character
|
||||
@findex @code{NEW_LINE} intrinsic
|
||||
@findex @code{NEW_LINE} intrinsic
|
||||
|
||||
@table @asis
|
||||
@item @emph{Description}:
|
||||
@code{NEW_LINE(C)} returns the new-line character
|
||||
|
||||
@item @emph{Standard}:
|
||||
F2003 and later
|
||||
|
||||
@item @emph{Class}:
|
||||
Elemental function
|
||||
|
||||
@item @emph{Syntax}:
|
||||
@code{C = NEW_LINE(C)}
|
||||
|
||||
@item @emph{Arguments}:
|
||||
@multitable @columnfractions .15 .80
|
||||
@item @var{C} @tab The argument shall be a scalar or array of the
|
||||
type @code{CHARACTER}.
|
||||
@end multitable
|
||||
|
||||
@item @emph{Return value}:
|
||||
Returns a @var{CHARACTER} scalar of length one with the new-line character of
|
||||
the same kind as parameter @var{C}.
|
||||
|
||||
@item @emph{Example}:
|
||||
@smallexample
|
||||
program newline
|
||||
implicit none
|
||||
write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
|
||||
end program newline
|
||||
@end smallexample
|
||||
@end table
|
||||
|
||||
|
||||
|
||||
@node NINT
|
||||
@section @code{NINT} --- Nearest whole number
|
||||
@findex @code{NINT} intrinsic
|
||||
|
@ -2614,6 +2614,25 @@ simplify_nint (const char *name, gfc_expr * e, gfc_expr * k)
|
||||
}
|
||||
|
||||
|
||||
gfc_expr *
|
||||
gfc_simplify_new_line (gfc_expr * e)
|
||||
{
|
||||
gfc_expr *result;
|
||||
|
||||
if (e->expr_type != EXPR_CONSTANT)
|
||||
return NULL;
|
||||
|
||||
result = gfc_constant_result (BT_CHARACTER, e->ts.kind, &e->where);
|
||||
|
||||
result->value.character.string = gfc_getmem (2);
|
||||
|
||||
result->value.character.length = 1;
|
||||
result->value.character.string[0] = '\n';
|
||||
result->value.character.string[1] = '\0'; /* For debugger */
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
gfc_expr *
|
||||
gfc_simplify_nint (gfc_expr * e, gfc_expr * k)
|
||||
{
|
||||
|
@ -1,3 +1,8 @@
|
||||
2006-10-08 Tobias Burnus <burnus@net-b.de>
|
||||
|
||||
PR fortran/28585
|
||||
* gfortran.dg/new_line.f90: New test.
|
||||
|
||||
2006-10-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
|
||||
|
||||
* gcc.dg/builtins-config.h: Ensure we use -std=c99 on solaris2.
|
||||
|
7
gcc/testsuite/gfortran.dg/new_line.f90
Normal file
7
gcc/testsuite/gfortran.dg/new_line.f90
Normal file
@ -0,0 +1,7 @@
|
||||
! { dg-do run }
|
||||
! Checks Fortran 2003's new_line intrinsic function
|
||||
! PR fortran/28585
|
||||
program new_line_check
|
||||
implicit none
|
||||
if(achar(10) /= new_line('a')) call abort()
|
||||
end program new_line_check
|
Loading…
Reference in New Issue
Block a user