re PR fortran/31764 (NEW_LINE with array argument)

PR fortran/31764

	* simplify.c (gfc_simplify_new_line): NEW_LINE can be simplified
	even for non constant arguments.

	* gfortran.dg/new_line.f90: Add new checks.

From-SVN: r124482
This commit is contained in:
Francois-Xavier Coudert 2007-05-06 22:56:52 +00:00 committed by François-Xavier Coudert
parent 28fe1c4032
commit 22aef73f17
4 changed files with 26 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2007-05-07 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/31764
* simplify.c (gfc_simplify_new_line): NEW_LINE can be simplified
even for non constant arguments.
2007-05-06 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2007-05-06 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>

View File

@ -2641,13 +2641,8 @@ gfc_simplify_new_line (gfc_expr *e)
{ {
gfc_expr *result; gfc_expr *result;
if (e->expr_type != EXPR_CONSTANT)
return NULL;
result = gfc_constant_result (BT_CHARACTER, e->ts.kind, &e->where); result = gfc_constant_result (BT_CHARACTER, e->ts.kind, &e->where);
result->value.character.string = gfc_getmem (2); result->value.character.string = gfc_getmem (2);
result->value.character.length = 1; result->value.character.length = 1;
result->value.character.string[0] = '\n'; result->value.character.string[0] = '\n';
result->value.character.string[1] = '\0'; /* For debugger */ result->value.character.string[1] = '\0'; /* For debugger */

View File

@ -1,3 +1,8 @@
2007-05-07 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/31764
* gfortran.dg/new_line.f90: Add new checks.
2007-05-06 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2007-05-06 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/31201 PR fortran/31201

View File

@ -2,6 +2,19 @@
! Checks Fortran 2003's new_line intrinsic function ! Checks Fortran 2003's new_line intrinsic function
! PR fortran/28585 ! PR fortran/28585
program new_line_check program new_line_check
implicit none implicit none
if(achar(10) /= new_line('a')) call abort() character(len=10) :: a1
character(len=10) :: a2(2)
character(len=10), parameter :: a3 = "1234567890"
character(len=10), parameter :: a4(2) = "1234567890"
character(len=10), parameter :: a5(2) = repeat("1234567890",2)
if(achar(10) /= new_line('a')) call abort
if (iachar(new_line(a1)) /= 10) call abort
if (iachar(new_line(a2)) /= 10) call abort
if (iachar(new_line(a3)) /= 10) call abort
if (iachar(new_line(a4)) /= 10) call abort
if (iachar(new_line(a5)) /= 10) call abort
end program new_line_check end program new_line_check