* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117555
138bc75d-0d04-0410-961f-
82ee72b054a4
+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
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)
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);
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 *);
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 *);
* @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
+@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
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)
{
return simplify_nint ("NINT", e, k);
+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.
--- /dev/null
+! { 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